Local Environment: Windows XP system and xampp integrated environment.
Xampp installation directory: d:/xampp
1. Stop the running MySQL process
Copy codeThe Code is as follows:
> Net stop mysql
If it is not loaded as a service, you can directly close it in the Process Manager or service.
2. Start MySQL in Safe Mode
Go to the mysql directory and run it in the command line.
Copy codeThe Code is as follows:
> D:
> Cd xampp/mysql/bin
> Mysqld.exe -- skip-grant-tables
3. You will be able to access MySQL without a password.
Copy codeThe Code is as follows:
> Mysql-u root-p
Enter the password and press Enter.
4. Change the password
Copy codeThe Code is as follows:
> Use mysql
> Update user set Password = password ('new password') where User = 'root ';
> Flush privileges;
5. Start the MySQL Service
Close all MySQL processes in the task manager and start them with the following command.
Copy codeThe Code is as follows:
> Net start mysql