System: CentOS6.6 64-bit
Refer to the document (see the original URL): MySQL forgot root password under Linux How to do _ Baidu experience http://jingyan.baidu.com/article/1709ad80a8caf14634c4f013.html specific steps are as follows:
Modify the MySQL configuration file (default is/ETC/MY.CNF) and add a line under [Mysqld] Skip-grant-tables
- after saving the configuration file, restart the MySQL services service mysqld restart
- again into the MySQL command line mysql-uroot-p, enter the password when the direct return, will enter the MySQL database, this time according to the general process of modifying the root password. input: >use MySQL; Change database >update user SET Passord =password ("passwd") WHERE user= ' root '; Reset password >flush privileges; Refresh the MySQL system permissions related tables to prevent access after the change, or restart the MySQL server
- after the password has been modified, then follow the procedure in step 1, delete the line in the configuration file and restart the MySQL service, the new password will take effect.
Precautions
One copy can be copied as a backup before modifying the configuration file
Before restarting the MySQL service, it is best to disconnect the services associated with MySQL to avoid data loss.
MySQL forgot password under Linux