1. First confirm that no other person on the server is connected to the MySQL database. Because during the resetting of the MySQL Root Password, the MySQL database is completely out of the password-free status, other users can also log on and modify the MySQL information at will.
2. Modify MySQL Logon Settings:
# Vi/etc/My. CNF
In the [mysqld] section, add skip-grant-tables.
For example:
[Mysqld]
Skip-grant-tables
Save and exit VI.
3. Restart mysqld
#/Etc/init. d/MySQL restart
4. log on to and modify the MySQL Root Password
#/Usr/local/MySQL/bin/MySQL
Mysql> use MySQL;
Mysql> Update user SET Password = PASSWORD ('new-password') where user = 'root ';
Mysql> flush privileges;
Mysql> quit
5. Modify the MySQL Logon Settings.
# Vi/etc/My. CNF
Delete the skip-grant-tables added to the [mysqld] section.
Save and exit VI.
6. Restart mysqld
#/Etc/init. d/MySQL restart