I haven't used the mysql database for a long time, and my password has not been correct when I logged in today.
1. First run cmd as an administrator and enter the command line window.
2. Close the mysql service:
Enter net stop mysql under windows; prompt mysql service is stopping.
3. Input: mysqld --skip-grant-table
Seeing other information says: Starting demo from...... will appear on the screen.
It doesn’t matter if I get stuck there and show nothing.
4. Open a new cmd, you can run it without being an administrator.
Input: mysql -u root mysql
Successfully enter mysql
5.输入:UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
The newpassword in the above command is the new password you want to change
6. Input: FLUSH PRIVILEGES;
This step is very important, execute the update permission table.
7. Enter: \q
Exit mysql.
Note: After entering mysql, there will be mysql> in front. At this time, the input command needs to add a semicolon at the end, which means the command is over.
Reference: https://blog.csdn.net/sea_snow/article/details/82498791