• mysql忘记root登录密码


    没有过忘记密码的程序员是不完美的,对于Oracle忘记密码可以设置orapwdfile文件,

    Mysql其中一种方法是通过修改文件免密然后再进行密码的修改:

    1.忘记密码

    [root@leader ~]# mysql -uroot -p
    Enter password:
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
    [root@leader ~]#

    2.修改文件/etc/my.cnf

    修改文件前先停掉mysqld服务

    [root@leader ~]# service mysqld stop
    Stopping mysqld: [ OK ]
    [root@leader ~]#vi /etc/my.cnf

    [mysqld]
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    user=mysql
    # Disabling symbolic-links is recommended to prevent assorted security risks
    symbolic-links=0
    skip-grant-table   ##添加该参数跳过密码验证

    [mysqld_safe]
    log-error=/var/log/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid

    3,重启服务进行密码修改

    [root@leader ~]# service mysqld start
    Starting mysqld: [ OK ]
    [root@leader ~]# mysql -uroot -p
    Enter password:
    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> show databases;
    +--------------------+
    | Database |
    +--------------------+
    | information_schema |
    | mysql |
    | test |
    +--------------------+
    3 rows in set (0.00 sec)

    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
    mysql> update user set password=password('mysql123')where user='root' and host='localhost';
    Query OK, 0 rows affected (0.00 sec)
    Rows matched: 1 Changed: 0 Warnings: 0

    mysql>

  • 相关阅读:
    困难4. 寻找两个正序数组的中位数
    6. Z 字形变换
    学习mysql176. 第二高的薪水
    竞赛6194. 最小 XOR
    中等856. 括号的分数
    竞赛6193. 沙漏的最大总和
    竞赛2430. 对字母串可执行的最大删除数
    困难927. 三等分
    困难1235. 规划兼职工作
    学习下mysql175. 组合两个表
  • 原文地址:https://www.cnblogs.com/guipeng/p/11368518.html
Copyright © 2020-2023  润新知