Centos登录Mysql时忘记密码
Posted ッ浅沫、
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos登录Mysql时忘记密码相关的知识,希望对你有一定的参考价值。
Centos登录mysql时忘记密码解决办法:
1.停止Mysql服务(在mysql目录下)
./support-files/mysql.server stop
2.修改配置文件/etc/my.cnf
在[mysqld]下添加skip-grant-tables
意思是忽略密码
保存并退出
3.启动Mysql(在Mysql目录下)
/support-files/mysql.server start
4.修改密码
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 3 to server version: 3.23.56
Type ‘help;‘ or ‘h‘ for help. Type ‘c‘ to clear the buffer.
mysql> USE mysql ;
Database changed
mysql> UPDATE user SET Password = password ( ‘新的密码) WHERE User = ‘root‘ ;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql> flush privileges ;
Query OK, 0 rows affected (0.01 sec)
Type ‘help;‘ or ‘h‘ for help. Type ‘c‘ to clear the buffer.
mysql> USE mysql ;
Database changed
mysql> UPDATE user SET Password = password ( ‘新的密码) WHERE User = ‘root‘ ;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql> flush privileges ;
Query OK, 0 rows affected (0.01 sec)
mysql> quit
5.改回配置,重启服务(在Mysql目录下)
/support-files/mysql.server start
————————————————
版权声明:本文为CSDN博主「小楼看风云」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/linux_s2018/article/details/80762820
以上是关于Centos登录Mysql时忘记密码的主要内容,如果未能解决你的问题,请参考以下文章
CentOS 7.2 MySQL的root密码忘记时重置方法