• MYSQL5.6/5.7 数据库密码丢失问题处理(需重启)


    文章结构图:

    一、MYSQL5.6密码丢失

    1.  强行停止MYSQL

    丢失超级管理用户ROOT的密码是致命的,可以通过--skip-grant-tables参数来跳过权限表。

     

     

    停止MYSQL,强行杀进程。

     

     

    kill -9 2311 3068

    ps -ef |grep mysql

     

    2. 跳过权限启动数据库

    /usr/local/mysql5.6/bin/mysqld_safe --defaults-file=/etc/my3306.cnf --skip-grant-tables &

     

    3. 修改ROOT用户密码

    登陆数据库:

    mysql -S /tmp/mysql3306.sock

     

    修改密码:

    update mysql.user set password=PASSWORD('mysql01') where User='root'; --5.6修改语句

    update mysql.user set authentication_string=password('mysql01') where user='root';  --5.7修改语句

    flush privileges;

     

    4. 重启数据库测试

    强行关闭数据库:

    ps -ef |grep mysql

    kill -9 3131 3794

     

    正常启动数据库:

    /usr/local/mysql5.6/bin/mysqld_safe --defaults-file=/etc/my3306.cnf &

     

    测试登陆:

     

    修改成功。

     

    二、MYSQL5.7密码丢失

    1. 强行停止MYSQL

    同理5.6

     

    强行停止数据库:

    ps -ef |grep mysql

    kill -9 2123 3430

     

    ps -ef|grep mysql

     

    2. 跳过权限启动数据库

    /usr/local/mysql5.7/bin/mysqld_safe --defaults-file=/etc/my3307.cnf --skip-grant-tables &

     

    3.修改ROOT用户密码

    登陆并修改密码:

    mysql -S /tmp/mysql3307.sock

    update mysql.user set password=PASSWORD('mysql01') where User='root';            --5.6修改语句

    update mysql.user set authentication_string=password('mysql01') where user='root';  --5.7修改语句

    flush privileges;

     

    4.重启数据库测试

    强行关闭数据库:

    ps -ef |grep mysql

    kill -9 4028 5354

     

    正常启动数据库:

    /usr/local/mysql5.7/bin/mysqld_safe --defaults-file=/etc/my3307.cnf &

     

    测试登陆:

    mysql -S /tmp/mysql3307.sock -uroot -p'mysql01'

     

    注意正常情况下是这样修改:

    set password for 'root'@'localhost'=password('mysql');

     

  • 相关阅读:
    Can't remove netstandard folder from output path (.net standard)
    website项目的reference问题
    The type exists in both DLLs
    git常用配置
    Map dependencies with code maps
    How to check HTML version of any website
    Bootstrap UI 编辑器
    网上职位要求对照
    Use of implicitly declared global variable
    ResolveUrl in external JavaScript file in asp.net project
  • 原文地址:https://www.cnblogs.com/hmwh/p/9013706.html
Copyright © 2020-2023  润新知