误删除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. L1-032 Left-pad

    根据新浪微博上的消息,有一位开发者不满NPM(Node Package Manager)的做法,收回了自己的开源代码,其中包括一个叫left-pad的模块,就是这个模块把javascript里面的Re ...

  2. VS2012调用64位IIS Express

    在注册表键HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\WebProjects下添加DWORD "Use64BitIISExp ...

  3. 关于hot miami的沙盒生存俯视角射击游戏

    一些关卡设计元素 撞门杀 扇形视角

  4. <二叉树的基本操作>

    #include<stdio.h> #include<stdlib.h> #include<string.h> #define num 100 #define OK ...

  5. 在vmware中实现Ubuntu与win7(主机)之间同步实现共享文件

    作为linux的热衷者和初学者,我们在学习的过程中难免会碰到不少的问题,下面简单的介绍和总结一下,我是如何通过以下两种方法解决在vmware中实现Ubuntu与win7(主机)之间同步实现共享文件的. ...

  6. Magento如何设置产品的打折或者优惠价格

    促销是商家的必备武器,手段可以说是花样繁多.其中最有效最具吸引力的就是优惠券了.那么在Magento中如何添加优惠券呢? 修改位置:后台--促销--购物车价格规则 1.点击右上角的 添加新规则 按钮. ...

  7. .NET练习计算平方根

    1.新建Windows窗体 2.窗体中添加控件:TextBox(文本框).Button(按钮).和Label(标签) 3.为Button对象添加点击事件代码 点击事件代码设计思路 ①从文本框中获取输入 ...

  8. opencv-python教程学习系列5-处理鼠标事件

    前言 opencv-python教程学习系列记录学习python-opencv过程的点滴,本文主要介绍opencv-python处理鼠标事件,坚持学习,共同进步. 系列教程参照OpenCV-Pytho ...

  9. xdoj 1044---炸红花 (话说 小时候经常玩这个被虐。。。。qwq)

    // 我真的好笨 只会枚举 话说那个ac的370b到底是怎么做的 /(ㄒoㄒ)/~~ #include <iostream> #include <algorithm> usin ...

  10. HDU 1084:What Is Your Grade?

    Problem Description "Point, point, life of student!" This is a ballad(歌谣)well known in col ...