• MySQL 忘记 root密码 处理方法


    原文:互联网老辛 https://blog.51cto.com/xinsz08/1859063

    mysql 版本不同,修改密码的方法大同小异,但是有一定的区别:

    vim /etc/my.cnf
    加上 skip-grant-tables 
    systemctl restart mysqld
    mysql
    update mysql.user set authentication_string = password('123456') where user = 'root' ;
    quit;
    vim /etc/my.cnf
    去掉 skip-grant-tables 
    systemctl restart mysqld

    mysql 5.1

    1.确认没有人能够连接 MySQL 数据库。

    2.修改MySQL的登录设置:

    vim /etc/my.cnf

    在 [mysqld] 的段中加上一句:

    skip-grant-tables

    保存并且退出

    3.重新启动 

    systemctl restart mysqld

    4.修改 MySQL 的 root 密码

    mysql;
    use mysql;
    update user set password = password ( '123456' ) where user = 'root' and host = 'localhost';
    flush privileges ;
    quit;

    5.7 版本的数据库下的 user 表里面已经没有 password 了
    而是将加密后的用户密码存储在 authentication_string 字段下面

    update mysql.user set authentication_string = password('123456') where user = 'root' and host = 'localhost';

    5.将MySQL的登录设置修改回来

    vim /etc/my.cnf

    将刚才在 [mysqld] 的段中的 skip-grant-tables 删除

    6.重新启动mysqld

    systemctl restart mysqld;

    7.如果操作功能不完全,登录数据库:

    mysql -p
    alter mysql.user 'root'@'localhost' identified by '123456';
    select user,host,create_priv,super_priv,grant_priv,password_last_changed,account_locked from mysql.user;
    flush privileges;
    quit;

    ----------------------------------
    互联网老辛
    https://blog.51cto.com/xinsz08/1859063

  • 相关阅读:
    K
    A
    2017 Multi-University Training Contest
    第一章 概述
    校赛F 比比谁更快(线段树)
    POJ 3683 Priest John's Busiest Day
    POJ 2186 Popular Cows
    第十五周讨论
    线段树模板(单点更新,区间更新,RMQ)
    2-SAT问题(白书)
  • 原文地址:https://www.cnblogs.com/chang09/p/16578962.html
Copyright © 2020-2023  润新知