MySQL免密码登陆

1) 停止mysql服务:

sudo service mysql stop

(2)以安全模式启动MySQL:
sudo mysqld_safe --skip-grant-tables &

(3)MySQL启动之后就可以不用密码登陆了:
sudo mysql -uroot -p
(然后直接回车)

4.重新设置密码

update mysql.user set authentication_string=PASSWORD('××××'),plugin='mysql_native_password' where user='root';

(其中'xxxx'为新密码)

5.刷新数据库

flush privileges;

然后就可以用刚设置的新密码登陆了

猜你喜欢

转载自www.cnblogs.com/qscfyuk/p/11718408.html