1. Shut down the mysql database you are currently running. You can either end the mysql process or directly close the mysql server.
2. Close the database and click Run to start running. Enter cmd to enter the command line window. In this command line, enter the installation path of your database, if it is installed by default, it will be in c: \ Program Files \ MySQL Server 5.0 \ bin
3. Enter mysqld -- skip-grant-tables in this path and press Enter. This command means to start the database in safe mode.
4. If the above steps are successful, a small cursor will appear in the cmd window, and no prompt will pop up. This indicates that your database has been started, in this case, re-open a cmd window, enter the installation path of the mysql database, and enter mysql-uroot-p. This command means to log on to MySQL with a blank password, if it succeeds, you will see a prompt such as mysql>. At last, enter update mysql. user set password = PASSWORD ('new password') where User = 'root ';
In the new password, enter the password you want to modify, close all cmd windows, follow the first step to turn off your server, and then run your server again in the normal step, at this time, your root password is changed to the new password you just set.