Solution 1: stop mysql, open the DOS window in CMD, and enter net stop MYSQL in windows
2. in the CMD command line window, enter the MYSQL installation directory, for example, D:/MySQL Server 5.5/bin.
3. enter the mysql security mode, that is, when mysql is up, it can enter the database without entering the password.
Command: mysqld-nt -- skip-grant-tables or mysqld -- skip-grant-tables
4. open a new CMD command line window, enter mysql-uroot-p, and log on to MySQL using a blank password (press enter without entering the password)
5. enter the following command to modify the password of the root user (remember to use the password function)
Mysql> update mysql. user set password = PASSWORD ("new password") where user = "root ";
6. refresh the permission table
Mysql> flush privileges; (this step is required, otherwise some will not work)
7. exit
Mysql> quit
In this way, the mysql root has been reset, and the mysql-nt.exe( mysqld.exe) process is ended in the windows Task Manager, and you can restart MYSQL! (You can also restart the server in the window service)
Congratulations! your ROOT password has logged on to MYSQL!