1. Enter cmd as an administrator, enter the bin directory where MySQL is located, and enter in the command line: net stop mysql
2. After the mysql service stops, enter: mysqld --shared-memory --skip-grant-tables , the command prompt window is locked at this time, and we reopen a new command prompt window with administrator privileges.
3. Enter in the new command prompt window: mysql -uroot -p and press Enter, and press Enter directly when prompted to enter the password.
4. Enter: use mysql;
5. Enter: update user set authentication_string='' where user='root'; and set authentication_string to empty.
6. Execute first : flush privileges;
7. Input: alter user 'root'@'localhost' identified by 'newpassword'; newpassword is the new password to be set.