take windows as an example:
1. Close the running MySQL service. (Services.msc run stop service)
2. Open the DOS window and go to the Mysql\bin directory. (Enter CD: Return to C packing directory, general MySQL installed in program Files\mysql\mysql Server 5.5\bin)
3. Enter mysqld--skip-grant-tables carriage return. --skip-grant-tablesSkip permission Table authentication when starting the MySQL service.
4. Open a DOS window again (because the DOS window is no longer moving), go to the Mysql\bin directory (same as above).
5. Enter MySQL return and, if successful, the MySQL prompt > will appear.
6. Connection rights database: use MySQL;.
6. Change Password: Update user set Password=password ("111111") where user= "root"; (don't forget the last semicolon).
7. Refresh permissions (required steps): flush privileges;.
8. Quit quit.
9. Log off the system, and then enter, using the username root and the new password you just set to log in.
Note: 1, you can use the Select Host,user,password from Mysql.user in step 6; Query password, if the password is not encrypted without modification;
But most of them are encrypted, that is, the query is not possible;
2, before the modification of the My.ini configuration file to see if there is a password configuration;
3, because the MySQL version is not the same, the specific steps are like this, you can refer to, cannot completely move according to other people's cmd command;
MySQL database forgot root password