zoukankan      html  css  js  c++  java
  • 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>

  • 相关阅读:
    重写gallery 的 BaseAdapter
    excel数据导入DB
    更换 字体
    Android Activity跳转 Intent
    mpax5.0比mapx4.51多了些什么功能?
    [转载]INET控件的几点使用
    [转载]GIS基本概念集锦
    [转载]Microsoft.XMLHTTP对象
    等值线的绘制
    [转载]关于webbrowser,innet,xmlhttp获取网页源码的比较!
  • 原文地址:https://www.cnblogs.com/guipeng/p/11368518.html
Copyright © 2011-2022 走看看