• 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>

  • 相关阅读:
    1
    可测试性
    爬取信件信息(更新)
    爬虫爬取疫情数据存到文件
    python分析三国演义中出现次数最多的词作词频统计
    实验三
    scala统计学生成绩
    对于OpenCV的访问Mat元素的探究
    OpenCV+VS2017+Nivdia(待更新)
    Window10 CUDA和cunn安装
  • 原文地址:https://www.cnblogs.com/guipeng/p/11368518.html
Copyright © 2020-2023  润新知