您的位置:首页 > 运维架构 > Linux

centos mysql忘记密码

2016-03-26 12:24 471 查看
1.停止mysql 服务:service mysqld stop;

2.vim命令打开mysql配置文件my.cnf(位置一般为:/etc/my.cnf)

3.在mysqld进程配置文件中添加skip-grant-tables,添加完成后保存。

4.重新打开mysql服务:service mysqld stop;

5.登陆mysql:mysql -u root -p; 不用输入密码登录mysql;

6.update user set password=password('newpassword') where user='root' (5.7以前版本)

update user set authentication_string=password('newpassword') where user='root' (5.7及以后版本)

7.在mysqld进程配置文件中注释skip-grant-tables,添加完成后保存

8.重启mysql服务
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: