1. First check whether the MySQL database service is started, which can be found directly in the Server Manager's "services". If you start, close the service first, you can use the command line to close the command:
net stop MySQL
2. After the shutdown is complete, the command line window enters the bin directory under the MySQL installation location. If you forget to install the path, you can also find the service in the "services", double-click to see. After entering the bin directory, execute the following command in the command-line window:
Mysqld-nt--skip-grant-tables
This statement means that you can skip user authentication and enter Safe mode.
3. After completing the previous step, do not close the command line window. Reopen a new command-line window and execute the database connection command:
Mysql-u root-p
At this point you will find that you do not need a password or login successfully.
4. Execute the command to change the password:
Update mysql.user Set password = password (' XXXX ') where user = ' root ';
5. Last update, Exit is OK.
Mysql> Flush privileges;mysql> exit;
6. When you're done, restart the MySQL service. But sometimes the error "1067 cannot connect", which may be due to the 3306 port is occupied. Use the following command to view the process PID that occupies the port, usually mysqld.exe, and stop it.
Netstat–ano
MySQL database forgot password