Mysql forgets the root password 1 and stops the MYSQL service. In CMD, open the DOS window and enter net stop mysql.
2. in the CMD command line window, enter the MYSQL installation directory, such as E:/Program Files/MySQL Server 5.0/bin.
Demo command:
Enter e: enter,
Enter cd "E:/Program Files/MySQL Server 5.0/bin"
Note that double quotation marks must also be entered to enter the Mysql installation directory.
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
Note: Check the execution program in the MySQL/bindirectory. if some data libraries are mysqld.exe, change them to 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 (note: There is a "point" in the middle of mysql. user ")
Mysql> update mysql. user set password = PASSWORD ('New password') where User = 'root ';
6. refresh the permission table
Mysql> flush privileges;
7. exit
Mysql> quit
So MYSQL Super Administrator account ROOT has been reset, then in the task manager to end mysqld/mysqld-nt.exe this process, restart MYSQL! (You can also restart the server)
After MYSQL is restarted, you can log on to MYSQL with the newly set ROOT password!
Method 2:
Create pwdhf.txt in the installation directory of MySQL, and enter the text: set password for 'root' @ 'localhost' = PASSWORD ('*****');
The red part shows the new password to be set.
Use windows service management tools or task manager to stop the MySQL service (Task Manager K drops the mysqld-nt process)
Doscommand prompt to the bin directory under the MySQL installation directory. for example, my directory is D:/Program Files/MySQL Server 5.1/bin.
Then run: mysqld-nt -- init-file = ../pwdhf.txt
After the execution is complete, stop the MySQL database service (Job Manager K drops the mysqld-nt process), and then start MYSQL again in normal mode.