• 忘记 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>     # 成功
  • 相关阅读:
    机器任务——最小点覆盖
    树的统计
    农夫约翰
    关押罪犯
    题单
    加分二叉树(递归,区间DP)
    [动态规划] 斜率优化DP
    [树形DP] 换根DP
    [期望DP][SCOI2008] 奖励关
    [数位DP][AHOI2009] Luogu P4127 同类分布
  • 原文地址:https://www.cnblogs.com/zyybky/p/12359065.html
Copyright © 2020-2023  润新知