mysql5.7忘记密码及授权问题

vi /etc/my.cnf
找到skip-grant-tables
放到[mysqld]下面


重启mysql
service mysqld restart
用root账号登录mysql
mysql -u root
使用mysql中的mysql数据库
use mysql;
修改密码(5.7版):
update user set authentication_string = password("new password") where user="root" ;
修改密码(5.7以下版):
update user set authentication_string = password("new password") where user="root" ;
刷新数据库 flush privileges;
退出: quit;
打开mysql5.7的配置文件my.cnf,把刚增加这行:skip-grant-tables 删除掉 保存并退出(:wq)

重启mysql service mysqld restart

猜你喜欢

转载自www.cnblogs.com/lucky2017/p/13371800.html