What if mysql forgets its password sometimes? I will give a case and explanation! Solve the problem!
The actual operations in Windows are as follows:
1. Disable running MySQL.
2. Open the DOS window and go to the mysqlin directory.
3. Enter mysqld -- skip-grant-tables and press Enter. If no prompt is displayed, it is correct.
4. Open another DOS window (because the DOS window can no longer be moved) and go to the mysqlin directory.
5. Enter mysql and press Enter. If yes, a MySQL prompt is displayed.>
6. Connect to the permission database> use mysql; (> is the original prompt, don't forget the last semicolon)
6. Change the password:> update user set password = password ("520") where user = "root"; (do not forget the last semicolon)
7. Refresh permissions (required steps)> flush privileges;
8. Exit> q
9. log out of the system, log on to MySQL, and log on to MySQL with the username "root" and the new password "123456.
Step 1
C: Documents and SettingsAdministrator> cd D: webwww.2cto. comMysqlMySQL Se
Rver5.5in
C: Documents and SettingsAdministrator> d:
D: webwww.2cto. comMysqlMySQL Server5.5in> mysqld -- skip-grant-tables
Step 2
Microsoft Windows [version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.
C: Documents and SettingsAdministrator> cd D: webwww.2cto. comMysqlMySQL Se
Rver5.5in
C: Documents and SettingsAdministrator> d:
D: webwww.2cto. comMysqlMySQL Server5.5in> mysql
Welcome to the MySQL monitor. Commands end with; or g.
Your MySQL connection id is 1
Server version: 5.5.10 MySQL Community Server (GPL)
Copyright (c) 2000,201 0, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.
Type help; or h for help. Type c to clear the current input statement.
Mysql> use mysql;
Database changed
Mysql> update user set password = password ("520") where user = "root ";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Mysql> q
Bye
D: webwww.2cto. comMysqlMySQL Server5.5in>