首页 > 数据库技术 > 详细

MySQL 超级管理员密码忘记了,怎么处理

时间:2020-07-30 18:14:16      阅读:109      评论:0      收藏:0      [点我收藏+]
--skip-grant-tables    :跳过授权表
--skip-networking      :跳过TCP/IP连接
[root@master1 ~]# pkill mysqld
[root@master1 ~]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS! 
[root@master1 ~]# /etc/init.d/mysqld stop
Shutting down MySQL.. SUCCESS! 
[root@master1 ~]# systemctl start mysqld --skip-grant-tables
systemctl: unrecognized option --skip-grant-tables
[root@master1 ~]# service mysqld start --skip-grant-tables
Starting MySQL. SUCCESS! 
[root@master1 ~]# mysql

(1)关闭数据库

[root@master1 ~]# systemctl stop mysqld

(2)使用安全模式启动

[root@master1 ~]# mysqld_safe --skip-grant-tables --skip-networking &
或者
[root@master1 ~]# service mysqld start --skip-grant-tables --skip-networking

(3)登录数据库并修改密码

 

[root@master1 ~]# mysql

mysql> alter user root@localhost identified by mysql;
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql>
mysql> flush privileges;    # 手工加载授权表
mysql> alter user root@localhost identified by mysql;

 

(4)重启数据库到正常模式

[root@master1 ~]# service mysqld restart
Shutting down MySQL.. SUCCESS! 
Starting MySQL. SUCCESS!

MySQL 超级管理员密码忘记了,怎么处理

原文:https://www.cnblogs.com/dinghailong128/p/13404935.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!