mysql password forgotten how to restore

1. First find the mysql installation directory, find the .ini configuration file, to which skip-grant-tables to save the restart mysql after exiting in the [mysqld] this entry. Restart the service can restart mysql service process management system implemented in the window. or:   

Click "Start" -> "Run" (shortcut key Win + R).

  2. Start: Enter net stop mysql

  3. Stop: Enter the net start mysql

2. Then you can not enter a password to login. This time enter cmd inside mysql -u root -p password you can not log on, and appear password: you can directly enter into the time, does not appear ERROR 1045 (28000), but many operations will be limited, because we can not grant (Permission denied). According to the following process to go (red part of the input section, pink is displayed after the execution of the code without entering):

3. Enter the mysql database:

    mysql> use mysql;

4. 2. Set the new password to the root user, the blue part of their inputs:
MySQL> SET password = Update User password ( "New Password") WHERE User = "root";
Query the OK,. 1 rows affected (0.01 sec)
the Rows Matched : 1 Changed: 1 Warnings: 0

If the error is:

Error ERROR 1054 (42S22) after performing Unknown column 'password' in 'field list'

The cause of the error is mysql database under the 5.7 version has no password this field of, password field into a authentication_string

update user set authentication_string=password("新密码") where user="root"

 

5. 

3. Refresh database
MySQL> flush privileges;
Query the OK, 0 rows affected (0.00 sec)

4. Exit MySQL:
MySQL> quit
Bye

After changing for the better, and then modify the my.ini file, delete We just added "skip-grant-tables" line, save and exit and then restart mysql on it.


    

Guess you like

Origin www.cnblogs.com/qingdou/p/11701319.html