1. Change the password when the ROOT user password of the MYSQL database is known:
1. In the SHELL environment, use the mysqladmin command to set: mysqladmin-u root-p password "new password" and press enter to enter the old password.
2. In the mysql> environment, use the update command to directly update the data in the user table of the mysql database:
Update mysql. user set password = password ('new password') where user = 'root ';
Flush privileges;
Note: The mysql statement should end with a semicolon (;).
3. In the mysql> environment, run the grant command to modify the permissions of the root user.
Grant all on *. * to root @ 'localhost' identified by 'new password ';
2. What should I do if I forget the password of the ROOT user of the mysql database? The method is as follows:
1. Close the currently running mysqld service program: service mysqld stop must first add mysqld as a system service)
2. Use the mysqld_saft script to do not load the authorization table in safe mode) to start the mysqld service.
/Usr/local/mysql/bin/mysqld_saft -- skip-grant-table &
3. log on to the database as a root user with an empty password and reset the password of the ROOT user.
# Mysql-u root
Mysql> Update mysql. user set password = password ('new password') where user = 'root ';
Mysql> flush privileges;
This article is from my technology blog, please be sure to keep this source http://2605658.blog.51cto.com/2595650/1298279