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.56Type ‘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
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/SQL/12419.html