mysql5.7忘记root密码以及远程登录授权

2017-04-09  本文已影响0人  boweichan

修改root密码

如果mysql现在启动着,先停止服务.

1.使用安全模式启动

mysqld_safe --skip-grant-tables --skip-networking &

2.新开一个窗口,启动输入mysql启动mysql,此时不用输入密码就能进入控制台;
3.修改密码,mysql5.7的密码存储使用的是authentication_string字段,不是password字段。

update mysql.user set authentication_string = password('newpassword') 
where user='root' and host='localhost';

4.刷新权限

flush privileges;

5.重新启动mysql服务即可

授权远程登录

grant all privileges on database.table to user identified by 'pasword';
上一篇 下一篇

猜你喜欢

热点阅读