Method One:
1. Enter or in the DOS window net stop mysql5
net stop mysql
2, open a DOS window, this need to switch to the MySQL bin directory. In the bin directory, typically create a batch 1.bat, the content is Cmd.exe run a moment to switch to the current directory, and then entermysqld-nt --skip-grant-tables;
Or
mysqld --skip-grant-tables;
Do not close the window
3. Open a DOS window again, mysql -u root
4. Enter:
Copy CodeThe code is as follows: Use MySQL update user set Password=password ("New_pass") where user= "root"; Flush privileges; Exit
5, use the Task Manager, find the MYSQLD-NT process, end the process
or the following steps1, stop MySQL service, CMD Open DOS window, enter net stop MySQL 2, in cmd command Line window, go to MySQL installation directory such as E:\Program files\mysql\mysql Server 5.0\bin Demonstration command: Input E : Enter the CD "E:\Program files\mysql\mysql Server 5.0\bin" Note that double quotes are also entered so that you can enter the MySQL installation directory. 3, enter the MySQL security mode, that is, when MySQL up, you can enter the database without entering a password. Command: Mysqld-nt--skip-grant-tables 4, reopen a CMD command line window, enter mysql-uroot-p, use a blank password to log in to MySQL (Do not enter the password, directly press ENTER) 5, enter the following command to start modifying the root user's password (note: there is a "dot" in the middle of the Mysql.user command) mysql> update mysql.user set Password=password (' New password ') where user= ' Root '; 6, Refresh the permissions table mysql> flush privileges; 7, quit mysql> quit so the MySQL Super Admin account Root has been reset, the next in the Task Manager to end the Mysql-nt.exe this process, restart MySQL! (You can also restart the server directly) after MySQL restarts, you can log in to MySQL with the new root password!Method Two:First create a new pwdhf.txt in the MySQL installation directory, enter the text: SET PASSWORD for ' root ' @ ' localhost ' = PASSWORD (' * * * * * * ');
Red part for new password to be set with Windows Service Management tool or task Manager to stop the MySQL service (Task Manager k drop mysqld-nt process) DOS command prompt to the bin directory under the MySQL installation directory as mine is D:\Program files\ Mysql\mysql Server 5.1\bin then runs: Mysqld-nt--init-file=. /pwdhf.txt after execution stop MySQL database service (Task Manager k off Mysqld-nt process), and then restart MySQL in normal mode
A workaround for MySQL forgot root password under windows