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 |
Copy Code |
Skip-grant-tables |
Then restart your mysqld, so long without the password.
And then into MySQL.
The code is as follows |
Copy Code |
UPDATE Mysql.user SET Password=password (' Password ') WHERE user= ' root '; |
After success
The code is as follows |
Copy Code |
FLUSH privileges; |
Finally remove the skip-grant-tables from the MY.CNF
Restart Mysqld.
Windows action method
1. Kill off 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 |
Copy Code |
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 |
Copy Code |
Mysql-u Root |
4. Change the password of root user;
The code is as follows |
Copy Code |
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.