Mysql common password recovery methods

Source: Internet
Author: User

Mysql common password recovery methods/* 1. if you forget the MySQL root Password, use the following methods to reset the password: 1. KILL the MySQL process in the system;

Mysql tutorials
/*
I. One of the methods to restore the MySQL password
If you forget the MySQL root Password, You can reset it using the following methods:
1. KILL the MySQL process in the system;

Killall-TERM mysqld


2. Run the following command to start MySQL without checking its permissions;

Safe_mysqld -- skip-grant-tables &


3. Use the empty password to log on to MySQL as the root user;
Mysql-u root
4. Modify the password of the root user;

Mysql> update mysql. user set password = PASSWORD ('new password') where User = 'root ';
Mysql> flush privileges;
Mysql> quit


Restart MySQL to log on with the new password.

Ii. method 2

1. Edit the MySQL configuration file (the best combination with PHP:

In windows: % MySQL (the best combination with PHP) _ installdir % my. ini // I. ini is the configuration file of MySQL (the best combination with PHP.
In linux:/etc/my. cnf

Add the following line in the [MySQL (best combination with PHP) d] configuration section:
Skip-grant-tables

Save and exit editing.

2. Restart MySQL (the best combination of PHP and MySQL ).

In windows:
Net stop MySQL (the best combination with PHP)
Net start MySQL (the best combination with PHP)

In linux:
/Etc/init. d/MySQL (the best combination with PHP) d restart

3. Set a new ROOT password.

Then run the following command in the command line:
MySQL (the best combination with PHP)-uroot-p MySQL (the best combination with PHP)
Press enter without a password to go to the database tutorial.

Run the following statement to update the root password to 7758521:
Update user set password = PASSWORD ("7758521") where user = 'root ';

Quit exits MySQL (the best combination with PHP ).

4. Restore the configuration file and restart the service.

Then, modify the MySQL configuration file (the best combination with PHP) to delete the line added.

Restart MySQL (the best combination with PHP) again, and the password is changed.


Method 3

Mysql> Insert INTO mysql. user (Host, User, Password)

VALUES ('%', 'Jeffrey ', PASSWORD ('biscuit '));

Mysql> FLUSH PRIVILEGES

Specifically, this is adding a user with the username jeffrey and password biscuit. I wrote this example in mysql Chinese reference manual.

Be sure to use the PASSWORD function, and then use flush privileges.


Method 4

Use mysqladmin, which is a special case stated above.

Mysqladmin-u root-p password mypasswd


After entering this command, you need to enter the original root password, and then the root password will be changed to mypasswd. Change the root in the command to your username, and you can change your password.

Of course, if your mysqladmin cannot connect to mysql server, or you cannot execute mysqladmin, this method is invalid, and mysqladmin cannot clear the password.

The following methods are used at the mysql prompt and must have the root permission of mysql:

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.