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)
    
  • 相关阅读:
    从淘宝数据结构来看电子商务中商品属性设计
    YY淘宝商品数据库设计
    ElasticSearch-聚合bucket学习
    ElasticSearch-聚合bucket
    Elasticsearch(9) --- 聚合查询(Bucket聚合)
    Elasticsearch-多字段搜索(Multifield Search)和提高精确度
    五、设备管理与文件系统
    六、YUM仓库
    四、查找命令
    二、用户权限
  • 原文地址:https://www.cnblogs.com/gshelldon/p/14073164.html
Copyright © 2011-2022 走看看