当前位置:Gxlcms > 数据库问题 > 详解如何在Redhat Linux(CentOS)下重置MySQL根(Root)密码

详解如何在Redhat Linux(CentOS)下重置MySQL根(Root)密码

时间:2021-07-01 10:21:17 帮助过:14人阅读

1.首先输入“service mysqld status”查看当前mysql服务状态,下图显示正在mysqld服务正在运行中。

技术分享

2.输入“killall -TERM mysqld”命令停止所有的mysqld进程。

技术分享

3.输入“service mysqld stop”命令停止mysqld服务。

技术分享

4.输入“mysqld_safe  --skip-grant-tables &”命令以无密码方式进入MySQL安全模式。

技术分享

5.输入“mysql -u root”并按回车键即可。


6.输入“use mysql;”挂载数据库。

注意:请勿忘记在最后输入分号(;)。

技术分享

7.输入"update user set password=password("Redhat") where user=‘root‘"将Root密码修改为New9ssw0rd。

技术分享

8.输入"flush privileges;"更新权限。

技术分享

9.输入“quit”并按回车键退出。

注意:此处不需输入分号。

技术分享

10.输入"service mysqld restart"重启mysqld服务。

技术分享

11.输入“mysql -u root -p”并按回车键提示输入密码。

技术分享

12.输入新密码Redhat并按回车键,提示已经成功登录。


详解如何在Redhat Linux(CentOS)下重置MySQL根(Root)密码

标签:mysql root密码

人气教程排行