Article to introduce about the forgotten MySQL root password reset method, also introduced in different operating systems, the following describes the Linux and Windows solutions, there is a need for friends to understand.
If you forget the MySQL root password, you can reset it in the following ways:
Linux operating methods
In the MY.CNF [mysqld] field, add:
The code is as follows
Skip-grant-tables
Then restart your mysqld, so long without the password.
And then into MySQL.
The code is as follows
UPDATE Mysql.user SET Password=password
(' Password ') WHERE user= ' root ';
After success
The code is as follows
FLUSH privileges;
Finally remove the skip-grant-tables from the MY.CNF
Restart Mysqld.
How Windows operates
1. Kill the MySQL process in the system;
2. Use the following command to start MySQL, to do not check the permissions of the way to start;
The code is as follows
Mysqld_safe-skip-grant-tables &
3. Then use the null password method to log in to MySQL with root user;
The code is as follows
Mysql-u Root
4. Change the password of root user;
The code is as follows
mysql> Update Mysql.user Set Password=password (' New password ') where user= ' root ';
mysql> flush Privileges;
Mysql> quit
5. Restart MySQL, you can log in with the new password.