Depends on what you are in the system (Windows or Linux) under the MySQL, in general, the method is to open unsafe mode into MySQL, and then directly modify the MySQL database under the user table, remember update user set password= Password ("New password") where user= "root"; I wrote a meaning, password ("New password"), password () is a cryptographic function, not directly password= "new password"; Refer to the online tutorial, try it yourself, If you don't understand, ask again. Give it to me first. If you are prompted that MySQL is not a valid command, go to the bin directory below the directory of MySQL and then proceed or add it to the environment variable.
Ensure that the MySQL service is turned off, and if you have registered the service, use the command: net stop MySQL;
Turn on unsafe mode, that is, without permission verification (password Authentication), you can enter MySQL arbitrarily, using the command: Mysqld-nt--skip-grant-tables
Update Mysql.user set Password=password (' New password ') where user= ' root ' and host= ' localhost ';
Key step: Refresh permissions, using command: Flush privileges;
Close the command line,
Kill the Mysqld process, method: Go to the Task Manager and end the process Mysqld.exe.
Start MySQL service again, using the command net start MySQL.
This article is from the "Dusk Prayer" blog, please be sure to keep this source http://ailoveai5521.blog.51cto.com/3381210/1685318
MySQL database forgot root password