As the title says, I believe there are many solutions provided by Brother Lei Feng on the Internet. When I tried those methods, I encountered a problem and did not solve it successfully. , as for what the problem is, let me sort it out again.
You can execute the net stop mysql command on the command line or close it directly in the process manager.
You can also click Stop directly (if you are using wamp), as shown below:
First enter mysql The installation directory, such as D:\mysql\bin
Execution
D:\mysql\bin>mysqld.exe –skip-grant-tables
If nothing unexpected happens, the current window will enter hang at this time status,Do not close the window, reopen another command line windowExecute the following command
D:\mysql\bin>mysql -uroot -p
You will be prompted to enter the password at this time, ignore the password , press Enter directly to enter mysql.
mysql>use mysql;
mysql>update user set password=password(“new_password”) where user=”root”;
Then Here comes the problem. When you reach this step, you may report this error:
The modification failed. The reason is very simple. There is no password field in the table. So what exactly should be changed? It's very simple. You can know it by directly entering the user table and executing the following command:
mysql>How to reset mysql password * from user where user="root";
You can see the following output:
Obviously, there is no password field in the table, but there is a field authentication_string (authentication string) corresponding to a 64-bit encrypted string. Just replace password with authentication_string.
mysql>update user set authentication_string=password(“new_password”) where user="root”;
Then execute
mysql>flush privileges;
mysql>exit;
The password was modified successfully.
Just restart. If it cannot be restarted, you can restart the computer and then restart.
The above is the detailed content of How to reset mysql password. For more information, please follow other related articles on the PHP Chinese website!