zoukankan      html  css  js  c++  java
  • MYSQL误删用户故障解决案例

    误删下所有的用户

    # 删除一个用户(::1 是本机 ipv6 地址)
    mysql> drop user root@'::1';
    Query OK, 0 rows affected (0.00 sec)
    
    # 删除所有用户
    mysql> delete from mysql.user where 1=1;
    Query OK, 4 rows affected (0.00 sec)
    
    # 删除用户以后还是可以登陆,但是不要重启,重启就会出现故障报错
    
    解决方式一:
    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
    
    解决方式二:
    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)
    
    4.停止数据库&启动数据库
    [root@db02 scripts]# mysqladmin -uroot -p123 shutdown
    [root@db02 scripts]# systemctl start mysqld
    
  • 相关阅读:
    洛谷 P1474 货币系统 Money Systems 题解
    洛谷 P5146 最大差值 题解
    洛谷 P1880 [NOI1995]石子合并 题解
    洛谷 P1063 能量项链 题解
    洛谷 P3385 【模板】负环 题解
    洛谷 P1522 牛的旅行 Cow Tours 题解
    洛谷 P2212 [USACO14MAR]浇地Watering the Fields 题解
    浅谈 C 语言中模块化设计的范式
    内联函数(Inline Functions)
    C++中全局变量的声明和定义
  • 原文地址:https://www.cnblogs.com/Applogize/p/13278557.html
Copyright © 2011-2022 走看看