Modify the password of mysql5.7 under ubuntu16.04

First log in to mysql:

mysql -uroot -p

Next we will change the password

 
mysql>use mysql;

mysql>update user set authentication_string=password('新密码') where user='root';

 

 

Note: You may encounter such a problem. This is because your password is not strong enough. Please modify the strength, for example: @ROOT_root_123
Write picture description here

It’s not completely done yet, do not exit, here is just a modification, not saved yet,
continue to enter the following command:

 
mysql> flush privileges;

mysql> quit;

Well, you're done, modify the configuration file back, comment out skip-grant-tables, and restart,

sudo service mysql restart

Guess you like

Origin blog.csdn.net/weixin_39842528/article/details/97674620