zoukankan      html  css  js  c++  java
  • 忘记 mysql 密码

    第一节:忘记 mysql 密码

    1.1 停止服务

    [root@centos6 ~]# service mysqld stop
    停止 mysqld:                                              [确定]

    1.2 修改配置文件

    [root@centos6 ~]# vim /etc/my.cnf
    [mysqld]
    ......
    skip-grant-tables    # 在[mysqld]中加入该字段
    # Disabling symbolic-links is recommended to prevent assorted security risks

    1.3 重启服务,并登录

    [root@centos6 ~]# service mysqld start
    正在启动 mysqld:                                          [确定]
    [root@centos6 ~]# 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>

    1.4 切换当前数据库

    mysql> use mysql
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    
    Database changed

    1.5 修改密码

    mysql> update user set password=password('123456') where user='root' and Host = 'localhost';
    Query OK, 1 row affected (0.00 sec)
    Rows matched: 1  Changed: 1  Warnings: 0
    
    mysql> exit
    Bye

    1.6 停止服务,修改配置

    [root@centos6 ~]# service mysqld stop
    停止 mysqld:                                              [确定]
    [root@centos6 ~]# vim /etc/my.cnf
    [mysqld]
    ......
    # skip-grant-tables
    # Disabling symbolic-links is recommended to prevent assorted security risks
    
    [root@centos6 ~]# service mysqld start
    正在启动 mysqld:                                          [确定]
    [root@centos6 ~]# mysql -uroot -p123456
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 3
    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>     # 成功
  • 相关阅读:
    MongoDB学习(附录一) 安装mongodb3.6时碰到的问题
    详细图解mongodb下载、安装、配置与使用
    大数据时代的数据存储,非关系型数据库MongoDB
    python获取风和天气城市数据 ID
    智能车学习(二十一)——浅谈CCD交叉以及横线摆放
    智能车学习(二十)——浅谈C车硬连接与软连接
    智能车学习(十九)——硬件电路设计
    智能车学习(十八)——电机学习
    智能车学习(十七)——舵机学习
    智能车学习(十六)——CCD学习
  • 原文地址:https://www.cnblogs.com/zyybky/p/12359065.html
Copyright © 2011-2022 走看看