误删除 mySQL 用户解决办法
误删除用户解决办法
删除用户
删除用户
mysql> truncate mysql.user;
Query OK, 0 rows affected (0.05 sec)
mysql> select user,host from mysql.user;
Empty set (0.00 sec)
重启mysql服务并登录
[root@db01 ~]# systemctl restart mysqld
[root@db01 ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
#登录错误
恢复用户
当登录不上去首先停掉正在运行的数据库
[root@db01 ~]# systemctl stop mysqld
[root@db01 ~]# ps -ef |grep mysqld
root 7905 7664 0 03:22 pts/1 00:00:00 grep --color=auto mysqld
跳过授权表,跳过网络启动数据库
[root@db01 ~]# mysqld_safe --skip-grant-tables --skip-networking & -----跳过授权表,跳过网络
[1] 7908
[root@db01 ~]# 191101 03:26:40 mysqld_safe Logging to '/application/mysql/data/db01.err'.
191101 03:26:40 mysqld_safe Starting mysqld daemon with databases from /application/mysql/data
连接数据库
[root@db01 ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.44 Source distribution
Copyright (c) 2000, 2019, 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>
刷新授权表
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
创建 root 超级用户并退出
mysql> grant all on *.* to root@'localhost' identified by '123' with grant option;
Query OK, 0 rows affected (0.00 sec)
mysql> \q
Bye
停止mysql服务
[root@db01 ~]# mysqladmin -uroot -p123 shutdown
Warning: Using a password on the command line interface can be insecure.
191101 03:58:41 mysqld_safe mysqld from pid file /application/mysql/data/db01.pid ended
[1]+ Done mysqld_safe --skip-grant-tables --skip-networking
[root@db01 ~]# ps -ef |grep mysqld
root 8078 7664 0 03:59 pts/1 00:00:00 grep --color=auto mysqld
启动数据库服务
[root@db01 ~]# systemctl start mysqld
[root@db01 ~]# ps -ef |grep mysqld
mysql 8085 1 8 03:59 ? 00:00:00 /application/mysql/bin/mysqld --defaults-file=/etc/my.cnf
root 8108 7664 0 03:59 pts/1 00:00:00 grep --color=auto mysqld
连接数据库
[root@db01 ~]# 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.44 Source distribution
Copyright (c) 2000, 2019, 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>
查看创建的用户的权限
mysql> select * from mysql.user\G
*************************** 1. row ***************************
Host: localhost
User: root
Password: *23AE809DDACAF96AF0FD78ED04B6A265E05AA257
Select_priv: Y
Insert_priv: Y
Update_priv: Y
Delete_priv: Y
Create_priv: Y
Drop_priv: Y
Reload_priv: Y
Shutdown_priv: Y
Process_priv: Y
File_priv: Y
Grant_priv: Y -------------------------如果是N 就是不是超级用户权限
References_priv: Y
Index_priv: Y
Alter_priv: Y
Show_db_priv: Y
Super_priv: Y
Create_tmp_table_priv: Y
Lock_tables_priv: Y
Execute_priv: Y
Repl_slave_priv: Y
Repl_client_priv: Y
Create_view_priv: Y
Show_view_priv: Y
Create_routine_priv: Y
Alter_routine_priv: Y
Create_user_priv: Y
Event_priv: Y
Trigger_priv: Y
Create_tablespace_priv: Y
ssl_type:
ssl_cipher:
x509_issuer:
x509_subject:
max_questions: 0
max_updates: 0
max_connections: 0
max_user_connections: 0
plugin: mysql_native_password
authentication_string:
password_expired: N
1 row in set (0.00 sec)
注意:以上只能在存在数据的时候使用,如果没有数据直接初始化就可以。
误删除 mySQL 用户解决办法的更多相关文章
- mysql03--误删除了所有用户解决办法
误删除了所有用户解决办法 第一种方法(企业常用) 1.将数据库down掉 [root@db03 mysql]# /etc/init.d/mysqld stop Shutting down MySQL. ...
- 二.误删除MySQL用户,恢复方法
误删除MySQL用户导致无法进入数据库 一.方法一 1.停止数据库 [root@db02 ~]# /etc/init.d/mysqld stop 2.跳过授权表,跳过网络启动数据库 [root@db0 ...
- 导出oracle 到 mysql的解决办法
导出oracle 到 mysql的解决办法 使用sqluldr2 命令如下sqluldr2 USER=weibh/1234@dydb file=c:\1.txt sql=sql.sql FORMA ...
- [08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up IDEA2019的database插件无法链接mysql的解决办法(08001错误)
[08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up. 点击这里 ...
- 【数据库开发】is not allowed to connect to this MySQL server解决办法
ERROR 1130: Host '192.168.1.3′ is not allowed to connect to this MySQL server这是告诉你没有权限连接指定IP的主机,下面我们 ...
- Sql Server 孤立用户解决办法
Sql Server 孤立用户 是我们经常遇到的事情,今天详细的梳理了下,希望能帮到你 当把用户数据库从一台 Sql Server 使用备份和恢复的方式迁移到另一台服务器.数据库恢复以后,原先用户定义 ...
- 在centos6.5下用nginx无法连接zabbix与mysql的解决办法
一般情况下默认的webserver是apache.zabbix也不例外,官方文档全都是推荐用apache. 如果执意用nginx来做webserver的话,php引导需要再安装一个php-fpm.而且 ...
- mysql 死锁解决办法
查询表的时候,发现一圈圈转啊转,就是不出来数据,猜测表被锁住 解决办法 : mysql> show processlist ; mysql> kill 4; 说明 : 4为 i ...
- IDEA的database插件无法链接mysql的解决办法(08001错误)
1.问题 首先先说问题,用navicat链接数据库正常,mysql控制台操作正常,但是用IDEA的数据库插件链接一直报 08001 错误,具体见下图: 错误:Connection to eshop@l ...
随机推荐
- Jmeter BeanShell 执行多次问题,每发送一次请求执行一次BeanShell问题
前言:(此问题耗时半天) 提供解决思路的博主又有新问题了. 如图所示,写了一个BeanShell从文件中去获取值之后给测试计划的变量赋值. 问题来了,当禁用b的情况下,a只执行一次.当启用b请求的情况 ...
- 下载腾讯VIP视频
1.找到自己想看的VIP视频网页地址,比如我就喜欢看一周一更的天行九歌,链接地址:https://v.qq.com/x/cover/rm3tmmat4li8uul/i0031xd1vjf.html 2 ...
- Redis 相关功能和实用命令(五)
慢查询原因分析 由于 Redis 是单线程的,它内部维护了一个命令队列,所以当有耗时的命令出现时,比如 keys *,后面的命令会被阻塞,通查查出慢查询可以对服务进一步优化. 设置慢查询阀值:默认10 ...
- 决策树(基于增益率)之python实现
如图,为使用到的公式,信息熵表明样本的混乱程度,增益表示熵减少了,即样本开始分类,增益率是为了平衡增益准则对可取值较多的属性的偏好,同时增益率带来了对可取值偏小的属性的偏好,实际中,先用增益进行筛选, ...
- java-整型数值 用 16进制转换、2进制转换-Integer.toHexString
负数为什么要用补码表示 可以将符号位和其它位统一处理 减法也可按加法来处理 另外,两个用补码表示的数相加时,如果最高位(符号位)有进位,则进位被舍弃 正数:原码.反码.补码相同. 负数:反码符号位不变 ...
- 如何把安全证书导入到java中的cacerts证书库
每一步:进入某个https://www.xxx.com开头的网站,把要导入的证书下载, 在该网页上右键 >> 属性 >> 点击"证书" >> 再 ...
- Video/audio标签的一些基础使用心得
常用方法 .play():用于音频视频的播放 .pause():用于音频视频的暂停 常用属性 <audio src="Batmobile Battle Mode Reveal Musi ...
- Activity的四种加载模式详解:
先来看看总结图: 模式详解: standard模式: 标准启动模式,也是activity的默认启动模式.在这种模式下启动的activity可以被多次实例化,即在同一个任务中可以存在多个activity ...
- Golang 实现设计模式 —— 装饰模式
概念 "用于代替继承的技术,无需通过继承增加子类就能扩展对象的新功能" "动态地给一个对象添加一些额外的职责,就增加功能来说,装饰模式比生成子类更为灵活" 何时 ...
- SparkStreaming整合Flume的pull报错解决方案
先说下版本情况: Spark 2.4.3 Scala 2.11.12 Flume-1.6.0 Flume配置文件: simple-agent.sources = netcat-source simpl ...