MySQL 误删用户
误删除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 误删用户的更多相关文章
- MySQL 误删用户故障解决方案
目录 "误删"所有用户 解决方式一: 停止数据库 跳过 授权表 和 网络启动(重要) 插入新的用户 重启启动数据库 解决方式二: 停止数据库 跳过 授权表 和 网络启动(重要) 授 ...
- MySQL 误删数据、误更新数据(update,delete忘加where条件)
MySQL 误操作后数据恢复(update,delete忘加where条件) 关键词:mysql误删数据,mysql误更新数据 转自:https://www.cnblogs.com/gomysql/p ...
- Mysql创建用户并授权
运行命令行 mysql -uroot -p 登录mysql use mysql; 创建用户:create user 'test123'@'localhost' identified by '12345 ...
- mysql 操作用户权限
使用可以对mysql数据库用户表有操作权限的用户名登陆mysqlinsert into user(Host,User,Password) values('%','name','password');如 ...
- MySQL的用户和权限介绍
一.关于MySQL权限的几点常识: 1.MySQL的权限系统主要用来验证用户的操作权限. 2.在MySQL内部,权限信息存放在MySQL数据库的granttable里.当mysql启动后,grantt ...
- Mysql新增用户,权限管理
MySQL 赋予用户权限命令的简单格式可概括为:grant 权限 on 数据库对象 to 用户 一.grant 普通数据用户,查询.插入.更新.删除 数据库中所有表数据的权利. grant selec ...
- 详解MySQL的用户密码过期功能
这篇文章主要为大家详细介绍了MySQL的用户密码过期功能的相关资料,需要的朋友可以参考下 Payment Card Industry,即支付卡行业,PCI行业表示借记卡.信用卡.预付卡.电子钱包. ...
- mysql创建用户
mysql创建用户 创建用于localhost连接的用户并指定密码 mysql> create user 'pcom'@'localhost' identified by 'aaa7B2249' ...
- ubuntu下mysql添加用户的问题
在ubuntu下使用命令: $:sudo apt-get install mysql-server 命令安装的Mysql 版本为:Server version: 5.7.13-0ubuntu0.16. ...
随机推荐
- 相同类型的对象不能互相转换:java.lang.ClassCastException: com.anhoo.po.UserPo cannot be cast to com.anhoo.po.UserPo
@PostMapping("/findone") public String getone(UserVo userVo) throws IllegalAccessException ...
- path--diff
vdom--patch(一)我们讲了,整个Vue对象初始化并渲染到页面中的过程. 本篇文章我们主要来谈谈当页面绑定的数据修改后,是如何更新dom结构的, 即vdom的diff算法,网上讲解这部分内容的 ...
- 【ssm】拦截器的原理及实现
一.背景: 走过了双11,我们又迎来了黑色星期五,刚过了黑五,双12又将到来.不管剁手的没有剁手的,估计这次都要剁手了!虽然作为程序猿的我,没有钱但是我们长眼睛了,我们关注到的是我们天猫.淘宝.支付宝 ...
- cloneNode
- 【HDU5421】Victor and String(回文树)
[HDU5421]Victor and String(回文树) 题面 Vjudge 大意: 你需要支持以下操作: 动态在前端插入一个字符 动态在后端插入一个字符 回答当前本质不同的回文串个数 回答当前 ...
- Luogu 3246 序列
Luogu 3246 序列 考虑莫队,不算特别优秀,但足以通过此题. 用莫队做,先考虑在当前区间右边加入一个数对答案的影响,其他三种情况同理. 若加入新数的区间为 \([L,R]\) ,那么加的贡献就 ...
- 拒绝了对对象 '****'(数据库 '******',所有者 '***')的 SELECT 权限
数据库(xxx) --->安全性---->架构---->dbo(属性)--->权限--->添加--->浏览-->public 添加 select 等您需要的权 ...
- (1)什么是socket(套接字)
什么是套接字socket socket把传输层以下的协议都封装成了简单的接口,我编写基于网络通信的软件只需要调用这些接口即可,写出的程序自然是遵循tcp/udp协议的.... 什么是互联网 互联网=物 ...
- CTF-练习平台-Misc之 多种方法解决
五.多种方法解决 题目提示:在做题过程中你会得到一个二维码图片 下载文件后解压发现是一个exe文件,打开后报错:将文件后缀名改为txt打开后发现是base64编码 联系到提示说最后是一个二维码,将它转 ...
- jquery的常用操作(操作html页面的Dom对象的元素)
一:页面加载完成时,会执行jquery的方法(不需要等待图片加载完成,只要dom结构加载完成,就执行该方法) //第一种写法: $(document).ready(function() { // 执行 ...