zoukankan      html  css  js  c++  java
  • 企业案例-Mysql误删除用户表如何恢复

    1.不小心删除了mysql所有用户

    mysql> delete from mysql.user where 1=1;
    Query OK, 5 rows affected (0.00 sec)
    
    #删除用户以后还是可以登陆,但是不要重启
    

    2.解决方式一:

    1)停止数据库

    #抽根烟冷静一下
    [root@db02 scripts]# systemctl stop mysqld
    

    2)跳过授权表和网络启动

    [root@db02 scripts]# mysqld_safe --skip-grant-tables --skip-networking &
    

    3)插入新的用户

    insert into mysql.user values ('localhost','root',PASSWORD('123'),
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    'Y',
    '',
    '',
    '',
    '',0,0,0,0,'mysql_native_password','','N');
    

    4)重启启动数据库

    [root@db02 scripts]# mysqladmin shutdown
    200709 16:27:19 mysqld_safe mysqld from pid file /usr/local/mysql/data/db02.pid ended
    [1]+  Done                    mysqld_safe --skip-grant-tables --skip-networking
    [root@db02 scripts]# systemctl start mysqld
    

    3.解决方式二:

    1)停止数据库

    #抽根烟冷静一下
    [root@db02 scripts]# systemctl stop mysqld
    

    2)跳过授权表和网络启动

    [root@db02 scripts]# mysqld_safe --skip-grant-tables --skip-networking &
    

    3)授权一个新用户

    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> grant all on *.* to root@'localhost' identified by '123' with grant option;
    Query OK, 0 rows affected (0.00 sec)
    
  • 相关阅读:
    记事本+hhc生成CHM
    在Delphi里实现[int map string]对
    U盘插入拔出提示
    Delphi研发笔试试卷 我的小解
    Excel也能用SQL查询
    访问JAVA中的字段(jfieldID)
    调用JAVA方法
    缓存字段ID和方法ID
    JNI引用
    访问数组(JNI)
  • 原文地址:https://www.cnblogs.com/gshelldon/p/14073164.html
Copyright © 2011-2022 走看看