First, in a known MySQL database root user password, the method of modifying the password:
1, in the shell environment, using the Mysqladmin command set: mysqladmin–u root–p password "New password" Enter the old password required
2, in the mysql> environment, using the Update command, directly update the MySQL library user table data:
Update Mysql.user Set Password=password (' New password ') where user= ' root ';
Flush privileges;
Note: The MySQL statement ends with a semicolon ";"
3, in the mysql> environment, use the grant command to modify the root user's authorization permissions.
Grant all on *.* to root@ ' localhost ' identified by ' new password ';
Second, if you have forgotten the MySQL database root user password, and how to do it? The method is as follows:
1, close the currently running MYSQLD Service Program: Service mysqld Stop (to add mysqld first to the system services)
2. Use the Mysqld_saft script to start the MYSQLD service in Safe mode (without loading the authorization table)
/usr/local/mysql/bin/mysqld_saft--skip-grant-table &
3, use the null password root user login to the database, reset the root user password
#mysql-u Root
Mysql> Update Mysql.user Set Password=password (' New password ') where user= ' root ';
mysql> flush Privileges;
Note: The above command is case-insensitive
This article is from the "Soldier" blog, please be sure to keep this source http://ganbing.blog.51cto.com/7002794/1217697
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/database/MySQL/