zoukankan      html  css  js  c++  java
  • CentOS6.8下MySQL数据库忘记root密码解决方法

    一、更改my.cnf配置文件

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

    重启mysql服务:services mysqld restart

    二、更改root密码

    重启mysqld服务后,执行mysql命令,进入mysql命令行:

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

    修改root密码

    mysql> UPDATE mysql.user SET Password=PASSWORD('mysqladmin') where USER='root';
    Query OK, 0 rows affected (0.00 sec)
    Rows matched: 3  Changed: 0  Warnings: 0
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> exit
    Bye
    

    三、删除/etc/my.cnf中的skip-grant-tables,或者注释掉,重启mysql即可。

  • 相关阅读:
    随笔(二十三)
    随笔(二十二)
    随笔(二十一)
    Python3——2019年全国大学生计算二级考试
    IP组播-PIM协议
    PIM-DM实验
    组播基础原理——IGMP
    路由器反射与联盟
    路由过滤&路由引入实验练习
    有道云免会员更换背景图
  • 原文地址:https://www.cnblogs.com/vurtne-lu/p/7615681.html
Copyright © 2011-2022 走看看