误删除root用户&误删除所有用户

 #-------------------------------------------------------------------------------
#忘记root密码 登录并修改root密码 beign
#------------------------------------------------------------------------------- mysqld_safe --skip-grant-tables --skip-networking &
[root@db01-sa ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.38 Source distribution Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed
mysql> update user set password=PASSWORD('') where user='root' and host='localhost';
Query OK, 1 row affected (0.98 sec)
Rows matched: 1 Changed: 1 Warnings: 0 [root@db01-sa ~]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL.180620 13:09:10 mysqld_safe mysqld from pid file /application/mysql/data/db01-sa.pid ended
.... SUCCESS!
[]+ Done mysqld_safe --skip-grant-tables --skip-networking [root@db01-sa ~]# mysql -uroot -p123
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.38 Source distribution Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> #-------------------------------------------------------------------------------
#忘记root密码 登录并修改root密码 end
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
#误删除所有用户 beign
#------------------------------------------------------------------------------- #模拟情况
select user,host,password from mysql.user;
mysql> drop user root@'localhost'; #开始处理
[root@db01-sa ~]# /etc/init.d/mysqld stop
[root@db01-sa ~]#mysqld_safe --skip-grant-tables --skip-networking &
[root@db01-sa ~]# mysql mysql> INSERT INTO mysql.user VALUES ('localhost','root',
-> '','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');
Query OK, 1 row affected (0.00 sec) mysql> update mysql.user set password=PASSWORD('') where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0 mysql> select user,host,password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| root | localhost | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
+------+-----------+-------------------------------------------+
row in set (0.08 sec) [root@db01-sa ~]# /etc/init.d/mysqld restart
Shutting down MySQL..180620 13:19:15 mysqld_safe mysqld from pid file /application/mysql/data/db01-sa.pid ended
SUCCESS!
Starting MySQL..... SUCCESS!
[]+ Done mysqld_safe --skip-grant-tables --skip-networking
[root@db01-sa ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@db01-sa ~]# mysql -uroot -p123
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.38 Source distribution Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> select user,host,password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| root | localhost | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
+------+-----------+-------------------------------------------+
1 row in set (0.00 sec) #-------------------------------------------------------------------------------
#误删除所有用户 end
#-------------------------------------------------------------------------------

其实做到以上下面的就不用看了

############################################################################

如果遇到以上处理权限不足的补充处理

----add begin  by nod 18-06-21------

备注:可能会有权限不够的情况
处理方式: INSERT INTO mysql.user VALUES ('localhost','root',
'','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'); mysql> update mysql.user set password=PASSWORD('') where user='root'; [root@db01-sa ~]# /etc/init.d/mysqld restart
Shutting down MySQL..180621 08:08:27 mysqld_safe mysqld from pid file /application/mysql/data/db01-sa.pid ended
SUCCESS!
Starting MySQL..... SUCCESS!
[]+ Done mysqld_safe --skip-grant-tables --skip-networking
[root@db01-sa ~]# mysql -uroot -p123
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.38 Source distribution Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

----add end  by nod 18-06-21------

MySQL 误删用户的更多相关文章

  1. MySQL 误删用户故障解决方案

    目录 "误删"所有用户 解决方式一: 停止数据库 跳过 授权表 和 网络启动(重要) 插入新的用户 重启启动数据库 解决方式二: 停止数据库 跳过 授权表 和 网络启动(重要) 授 ...

  2. MySQL 误删数据、误更新数据(update,delete忘加where条件)

    MySQL 误操作后数据恢复(update,delete忘加where条件) 关键词:mysql误删数据,mysql误更新数据 转自:https://www.cnblogs.com/gomysql/p ...

  3. Mysql创建用户并授权

    运行命令行 mysql -uroot -p 登录mysql use mysql; 创建用户:create user 'test123'@'localhost' identified by '12345 ...

  4. mysql 操作用户权限

    使用可以对mysql数据库用户表有操作权限的用户名登陆mysqlinsert into user(Host,User,Password) values('%','name','password');如 ...

  5. MySQL的用户和权限介绍

    一.关于MySQL权限的几点常识: 1.MySQL的权限系统主要用来验证用户的操作权限. 2.在MySQL内部,权限信息存放在MySQL数据库的granttable里.当mysql启动后,grantt ...

  6. Mysql新增用户,权限管理

    MySQL 赋予用户权限命令的简单格式可概括为:grant 权限 on 数据库对象 to 用户 一.grant 普通数据用户,查询.插入.更新.删除 数据库中所有表数据的权利. grant selec ...

  7. 详解MySQL的用户密码过期功能

    这篇文章主要为大家详细介绍了MySQL的用户密码过期功能的相关资料,需要的朋友可以参考下   Payment Card Industry,即支付卡行业,PCI行业表示借记卡.信用卡.预付卡.电子钱包. ...

  8. mysql创建用户

    mysql创建用户 创建用于localhost连接的用户并指定密码 mysql> create user 'pcom'@'localhost' identified by 'aaa7B2249' ...

  9. ubuntu下mysql添加用户的问题

    在ubuntu下使用命令: $:sudo apt-get install mysql-server 命令安装的Mysql 版本为:Server version: 5.7.13-0ubuntu0.16. ...

随机推荐

  1. DevExpress v17.2新版亮点—.NET Reporting篇(一)

    用户界面套包DevExpress v17.2日前终于正式发布,本站将以连载的形式为大家介绍各版本新增内容.本文将介绍了.NET Reporting v17.2 的新功能,快来下载试用新版本! All ...

  2. MyEclipse持续性开发教程:用JPA和Spring管理数据(三)

    MyEclipse红运年货节 在线购买低至69折!火爆开抢>> [MyEclipse最新版下载] 本教程介绍了MyEclipse中的一些基于JPA / Spring的功能.有关设置JPA项 ...

  3. 关于junk jack

    旨在利用一切物品打造你自己的世界.你需要砍树获得木头,挖各种矿石用火炉炼成不同东西,顺便得到不同颜色材质的石头建房子,打各种家禽获得吃的甚至烘焙.养起来繁殖,天上掉下的星星.捡到圣诞礼包中的袜子都可以 ...

  4. 福大软工1816 - 第八次作业(课堂实战)- 项目UML设计

    团队 学号 姓名 本次作业博客链接 031602428 苏路明(组长) https://www.cnblogs.com/Sulumer/p/9822854.html 031602401 陈瀚霖 htt ...

  5. <constant name="struts.devMode" value="false" />

    在开发中,我们常常会遇到<constant name="struts.devMode" value="false" />,这是struts2的特性, ...

  6. SHA1

    整理于互动百科 安全哈希算法(Secure Hash Algorithm)主要适用于数字签名标准(Digital Signature Standard DSS)里面定义的数字签名算法(Digital ...

  7. php 从2维数组组合为四维数组分析

  8. JDK中Integer类的进制转换实现

    JDK中关于Integer类的进制转换方法很精巧,具体实现如下: final static char[] digits = { '0' , '1' , '2' , '3' , '4' , '5' , ...

  9. A+B for Input-Output Practice (VIII)

    A+B for Input-Output Practice (VIII) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/3276 ...

  10. QLabel 内容长度超过控件本身长度时超出的部分用省略号

    void JunEditableLabel::setText(const QString &string) { QFont font("Tahoma"); font.set ...