• 忘记 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>     # 成功
  • 相关阅读:
    cnblog项目--20190309
    django js引入失效问题
    Python老男孩 day16 函数(六) 匿名函数
    Python老男孩 day16 函数(五) 函数的作用域
    Python老男孩 day15 函数(四) 递归
    Python老男孩 day15 函数(三) 前向引用之'函数即变量'
    Python老男孩 day15 函数(二) 局部变量与全局变量
    Python老男孩 day14 函数(一)
    Python老男孩 day14 字符串格式化
    Python老男孩 day14 集合
  • 原文地址:https://www.cnblogs.com/zyybky/p/12359065.html
Copyright © 2020-2023  润新知