CentOS6.8下MySQL数据库忘记root密码解决方法

前端之家收集整理的这篇文章主要介绍了CentOS6.8下MySQL数据库忘记root密码解决方法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

一、更改my.cnf配置文件

编辑/etc/my.cnf文件,在[MysqLd]下添加skip-grant-tables,保存退出


重启MysqL服务:services MysqLd restart


二、更改root密码

重启MysqLd服务后,执行MysqL命令,进入MysqL命令行:


  1. [root@yeebian ~]# MysqL
  2. Welcome to the MysqL monitor. Commands end with ; or \g.
  3. Your MysqL connection id is 2
  4. Server version: 5.1.73 Source distribution
  5. Copyright (c) 2000,2013,Oracle and/or its affiliates. All rights reserved.
  6. Oracle is a registered trademark of Oracle Corporation and/or its
  7. affiliates. Other names may be trademarks of their respective
  8. owners.
  9. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  10. MysqL>

修改root密码

  1. MysqL> UPDATE MysqL.user SET Password=PASSWORD('MysqLadmin') where USER='root';
  2. Query OK,0 rows affected (0.00 sec)
  3. Rows matched: 3 Changed: 0 Warnings: 0
  4. MysqL> flush privileges;
  5. Query OK,0 rows affected (0.00 sec)
  6. MysqL> exit
  7. Bye
三、删除/etc/my.cnf中的skip-grant-tables,或者注释掉,重启MysqL即可。

猜你在找的CentOS相关文章