The password is many, sometimes even oneself forgot. This article is a solution to the Windows environment, forget the MySQL database root password.
1. First check that the MySQL service is started and stop the service if it is started. Available in the cmd window, using the command: net stop MySQL
2. In the cmd window, switch to the bin directory of the MySQL installation directory and run the command:
Mysqld--defaults-file= "D:\app\MySQL\MySQLServer5.5\my.ini"--console--skip-grant-tables
Upstream command explanation: through the security check, the MySQL service is turned on, so when you connect MySQL, you can not enter the user password.
3. Open another CMD window to connect to MySQL. Use the command:
Input command:mysql-uroot-p
Window display: Enter Password:
Enter directly here without entering the password. When you enter, you will be able to log in successfully.
4. After successful login, use the following command to reset the root password:
Switch database command: use MySQL;
Reset root New password: UPDATE user SET Password=password ('newpassword') where user= ' root ';
Refresh permissions: Flush privileges;
Quit Login: Quit
Re-login: mysql-uroot-p
Enter Password: Enter Password:newpassword
MySQL Root password forgotten solution (Windows environment)