mysql 忘记root密码

1、停止服务:

service mysqld stop

2、修改my.cnf:

1 vim /etc/my.cnf
2 
3 # 添加
4 skip-grant-tables

3、启动服务:

service mysqld start

4、登陆并修改密码:

1 # 登陆数据库
2 mysql
3 # 修改密码
4 update mysql.user  set password=password('newpassword') where user='root'

5、密码修改完成后,将my.cnf文件中添加的skip-grant-tables语句注释或删除掉,然后重启数据库即可

 

posted @ 2017-06-30 16:04  L狗哥  阅读(168)  评论(0编辑  收藏  举报