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

posted @ 2020-07-24 14:35  敬芝  阅读(254)  评论(0编辑  收藏  举报