1. Open the my.ini file in the MySQL directory, add a line of "skip-grant-tables" (password-free login) at the end of the file, save and close the file, and restart the MySQL service.
2. Enter the MySQL BIN directory through the command line, enter "mysql -u root -p" (no password), and press Enter to enter the database.
3. Execute "use mysql;" to use the mysql database.
4. Change the password: execute "update MySQL.user set authentication_string=password('root') where user='root'" (the password field no longer exists in the newly installed MySQL 5.7 database, and the password field is changed to authentication_string).
5. Open the my.ini file in the MySQL directory, delete the "skip-grant-tables" in the last line, save and close the file. Restart the MySQL service and enter "mysql -u root -p root" on the command line to successfully connect to the database.
Then there is an error when logging in to SQLyog, the error number 1862: your password has expired. Solution Enter the database through the command line and enter
mysql> SET PASSWORD = PASSWORD('root'); The problem is solved.