zoukankan      html  css  js  c++  java
  • 1、mysql学习之密码丢失恢复

    现象:mysql账号密码登陆失败或者忘记密码
    分析:
    对于mysql登陆忘记密码的情况有两种恢复方式,一种选择mysql_safe的方式重新启动mysql实例进行修改密码。一种为修改mysql配置文件再进行修改密码。两种方式的原理一样
     
    步骤:
    一、通过mysql_safe方式进行修改密码
    1、启动mysql实例
    # bin/mysql_safe --user=mysql --skip-grant-tables &    //启动mysql实例
     
    2、修改mysql密码
    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('123') where user='root' ;
    Query OK, 4 rows affected (0.01 sec)
    Rows matched: 4 Changed: 4 Warnings: 0
     
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
     
    二、通过修改my.cnf配置文件进行密码恢复
    1、修改my.cnf配置文件
    [root@iZ28gd6x9vfZ mysql]# vi my.cnf 
    在配置文件中添加skip-grant-tables

    2、重启mysql脚本并且登录mysql

    3、配置密码
    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('123') where user='root' ;
    Query OK, 4 rows affected (0.01 sec)
    Rows matched: 4 Changed: 4 Warnings: 0
     
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    4、还原配置文件,并且重启mysql
    5、重新登录mysql,密码123
    备注:mysql5.7账号密码认证有些调整,但没太大变化
  • 相关阅读:
    P1268 树的重量
    P2419 [USACO08JAN]牛大赛Cow Contest
    P1306 斐波那契公约数
    P2905 [USACO08OPEN]农场危机Crisis on the Farm
    P1081 开车旅行
    P2906 [USACO08OPEN]牛的街区Cow Neighborhoods
    P1550 [USACO08OCT]打井Watering Hole
    P2746 [USACO5.3]校园网Network of Schools
    P1613 跑路
    【BZOJ4868】期末考试(整数三分)
  • 原文地址:https://www.cnblogs.com/xiangys0134/p/7550267.html
Copyright © 2011-2022 走看看