温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

CentOS忘记root用户密码的解决方法

发布时间:2020-05-27 21:17:32 来源:亿速云 阅读:614 作者:鸽子 栏目:系统运维

1、没有输入或输入错误的root用户密码,无法进入数据库:

# mysql -uroot -p

(1)没有输入root用户密码,直接回车:

CentOS忘记root用户密码的解决方法

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

CentOS忘记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;

CentOS忘记root用户密码的解决方法

5、重启数据库:

# killall mysqld

# pkill mysqld

# ps -ef | grep mysql

# ss -tunlp | grep 3306

# systemctl start mysqld

6、输入root用户新设置的密码root@1234,进入数据库:

# mysql -uroot -p

CentOS忘记root用户密码的解决方法

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI