1. Precautions for mysql reset password
From mysql8 and after mysql8, mysql cannot be set in the configuration file my.ini skip-grant-tables
for password-free login.
If mysql8 configures this skip-grant-tables
, then the mysql -uroot -p login will not only fail to log in without password, but
will also cause the mysql service to automatically shut down.
2. mysql8 password-free login
(1) First, open the cmd command line as an administrator . If you do not open the following operations as an administrator, an error will occur. (2) If the mysql service has been started, then close it first. (3) Start without a password: If this is displayed, the start is successful.net stop mysql
mysqld --console --skip-grant-tables --shared-memory
(4) Key step: Open another cmd command line as an administrator.
Enter mysql -uroot -p, when asked to enter a password, you can log in directly without password when you go back to the city.
(5) Then change the password: refer to the second big step in my blog "Change the mysql password" https://blog.csdn.net/qq_41231694/article/details/123800517?spm=1001.2014.3001.5502