欢迎光临散文网 会员登陆 & 注册

解决yum方式安装的MySQL 5.7 root用户密码丢失问题

2021-11-02 11:30 作者:Vecloud_  | 我要投稿


1、没有输入或输入错误的root用户密码,无法进入数据库: 
# mysql -uroot -p 
(1)没有输入root用户密码,直接回车: 

(2)输入错误的root用户密码: 

2、强制结束MySQL进程: 
# yum -y install psmisc 
# killall mysqld 
# pkill mysqld 
# ps -ef | grep mysql 
# ss -tunlp | grep 3306 
3、使用mysqld命令,增加--skip-grant-tables参数,跳过权限表,启动数据库: 
# mysqld --defaults-file=/etc/my.cnf --user=mysql --skip-grant-tables & 
# ps -ef | grep mysql 
# ss -tunlp | grep 3306 
4、使用mysql命令直接进入数据库,为root用户设置新的密码并刷新权限: 
# mysql 
mysql> use mysql; 
mysql> update user set authentication_string=password('root@1234') where user='root'; 
mysql> flush privileges; 

5、重启数据库: 
# killall mysqld 
# pkill mysqld 
# ps -ef | grep mysql 
# ss -tunlp | grep 3306 
# systemctl start mysqld 
6、输入root用户新设置的密码root@1234,进入数据库: 
# mysql -uroot -p

了解更多网络知识关注:http://www.vecloud.com/

解决yum方式安装的MySQL 5.7 root用户密码丢失问题的评论 (共 条)

分享到微博请遵守国家法律