mysql set initial password under windows

1. First find the my.ini configuration file in the installation directory, open the configuration file, find the [mysqld] line, save the file after adding skip-grant-tables below, and restart the mysql service.

 

2. Execute mysql -u root -p if the password is empty, press Enter directly;

usemysql

mysql>update mysql.user set authentication_string=password('123456') where user='root' and Host ='localhost';

 mysql>Flush privileges;

where newpassword is the new password of root.

(Maybe the previous version of the password is password, 5.7.11 is authentication_string, you can select * from user, check it out)

(老版本)update user set password=password("123456") where user="root";

(5.7.11)update user set authentication_string=password("123456") where user="root";


3. Remove the line that was just added to the my.ini configuration file and restart mysql.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325209852&siteId=291194637