linux 下 mysql 忘记密码怎么办

1. 检查mysql服务是否启动,如果启动,关闭mysql服务

 

 

 停止 mysql : 

service mysqld stop

 

 

 

 2.修改mysql的配置文件my.conf

 

 

  在文件的[mysqld]标签下添加一句:skip-grant-tables

 

 

 :wq 退出

 

3.重启数据库

 

 

 

4.登录数据库

mysql -u root 

 

 

 

 

5.修改密码

 

 

 其中 root_password 替换成新密码

update mysql.user set authentication_string=password('root_password') where user='root'

 

6.还原 /etc/my.cnf【重启mysql】

posted @ 2020-07-19 16:04  漸行漸遠  阅读(656)  评论(0编辑  收藏  举报