MySql forget password modification mode adapts to version 5.7 or above

  • 2021-08-21 21:45:26
  • OfStack

1. Stop the process of mysqld. exe first

2. Open cmd, enter the bin directory of your mysql and enter this command:


mysqld --skip-grant-tables

After the input is completed, this cmd window cannot be used. In addition, one is opened as shown in the figure:

3. Also enter the bin directory of mysql, enter mysql directly, and then enter the car. Now it is skipping password verification and linking to the database as shown in the figure:

4. Look at the library mysql. The user table in this library puts the user name and password of our login

If you are interested, you can check it by yourself

5. Special attention should be paid here to the fact that the field password is not included in the user table in versions above 5.7

The field password appears to be authentication_string, which can be changed by this statement


update mysql.user set authentication_string=password('123456') where user='root' and Host = 'localhost';

6. Final implementation:


flush privileges;

It's ok.


Related articles: