MySQL Recover admin password

Source: Internet
Author: User

Change MySQL prompt

mysql> prompt \[email protected] \r:\b:\s

Find to my database starting with

Mysql> show databases like ' my% '

Delete all Users

Mysql> Delete from Mysql.user;

Add User Rights

Mysql> Grant all privileges on * * to [e-mail protected] '% ' identified by ' 123qwe ' with GRANT option;

Immediate effect

mysql> flush Privileges;

View when full user rights and password conditions

Mysql> select User,host,password from Mysql.user;

Set a password for an administrator

Shell > mysqladmin-u System password ' 123qwe '

Change Password for administrator

1 , Shell > Mysqladmin-u system-p123qwe password ' 123123 '

2 , mysql> update mysql.user set Password=password ("456") where user= ' system ' and host= ' localhost ';

mysql> flush privileges;

3 , set Password=password ("123");

View table Structure

MySQL > desc mysql.user;


Retrieve the Lost MySQL Password

Shell>/etc/init.d/mysqld Stop

< Span style= "Font-family:tahoma, Sans-serif;" > shell> Mysqld_safe--skip-grant-tables–user=mysql & Single instance

shell>mysqld_safe--defaults-file=/data/3306/my.cnf--skip-grant-table & Multi-instance

Mysql>update Mysql.user Set Password=password ("456") whereuser= ' system ' and host= ' localhost ';

Mysql>flush privileges;

Shell> Mysqladmin-u-P shutdown



MySQL Recover admin password

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.