First start the command line
1. Run from the command line: taskkill /f /im mysqld-nt.exe
The following operations are to operate some programs in the bin directory of mysql. If no environment variables are configured, you need to switch to the bin directory of mysql and execute the following statements. Otherwise it will be invalid
2. Continue running on the command line: mysqld-nt --skip-grant-tables
3. Open a new command line and run: mysql -u root (if the bin environment variable of mysql is not configured, you need to switch to the bin directory to execute this statement)
If you don’t want to change the password, but just want to see the original password. You can execute this statement on the command line
select host,user,password from mysql.user;//You can view the user and password
If you want to change the password, execute the following statement on the command line
update mysql.user set password='Fill in the password you want to set here' where user='root';
Here I set a blank password.
After completing these operations, continue running on the command line
taskkill /f /im mysqld-nt.exe;//For safety reasons, end it first, because now you can log in directly with mysql -u root
net start mysql;//Start the mysql service
At this point, the solution to the forgotten root password of mysql is complete.
I am also a novice, there may be some low-level problems in this process, I hope you can give me some advice and criticism. Only by finding my own problems and solving them can I make progress. Let this newbie like me get wings as soon as possible. I also want to fly.