mysql数据库中管理员用户(root@localhost)被误删除,怎么恢复
来源:互联网 发布:mac如何移除桌面图标 编辑:程序博客网 时间:2024/05/21 14:50
正常状态:
[root@web01 data]# mysql-uroot -p123456
Warning: Using apassword on the command line interface can be insecure.
Welcome to the MySQLmonitor. Commands end with ; or \g.
Your MySQL connection idis 75
Server version: 5.6.34Source distribution
Copyright (c) 2000,2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registeredtrademark of Oracle Corporation and/or its
affiliates. Other namesmay be trademarks of their respective
owners.
Type 'help;' or '\h' forhelp. Type '\c' to clear the current input statement.
mysql> selectuser,host from mysql.user;
+-----------+--------------------------+
| user | host |
+-----------+--------------------------+
| root | 127.0.0.1 |
| wordpress |172.16.1.0/255.255.255.0 |
| root | ::1 |
| | localhost |
| root | localhost |
| | web01 |
| root | web01 |
+-----------+--------------------------+
7 rows in set (0.00 sec)
管理员用户被误删除后:
mysql> drop userroot@localhost;
Query OK, 0 rowsaffected (0.07 sec)
mysql> selectuser,host from mysql.user;
+-----------+--------------------------+
| user | host |
+-----------+--------------------------+
| root | 127.0.0.1 |
| wordpress |172.16.1.0/255.255.255.0 |
| root | ::1 |
| | localhost |
| | web01 |
| root | web01 |
+-----------+--------------------------+
6 rows in set (0.00 sec)
解决:
需要使用root@127.0.0.1用户登录系统(无密码),再创建root@localhost
[root@web01 data]# mysql-h 127.0.0.1 -uroot -p
Enter password:
Welcome to the MySQLmonitor. Commands end with ; or \g.
Your MySQL connection idis 80
Server version: 5.6.34Source distribution
Copyright (c) 2000,2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registeredtrademark of Oracle Corporation and/or its
affiliates. Other namesmay be trademarks of their respective
owners.
Type 'help;' or '\h' forhelp. Type '\c' to clear the current input statement.
mysql>
mysql>
mysql> selectuser,host,password from mysql.user;
+-----------+--------------------------+-------------------------------------------+
| user | host | password |
+-----------+--------------------------+-------------------------------------------+
| root | web01 | |
| root | 127.0.0.1 | |
| root | ::1 | |
| | localhost | |
| | web01 | |
| wordpress |172.16.1.0/255.255.255.0 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+-----------+--------------------------+-------------------------------------------+
6 rows in set (0.00 sec)
mysql> grant all on*.* to root@localhost identified by '123456' with grant option; #创建被删除的用户,并赋予超级权限
Query OK, 0 rowsaffected (0.00 sec)
mysql> flushprivileges;
Query OK, 0 rowsaffected (0.00 sec)
mysql> quit
Bye
恢复正常
[root@web01 data]# mysql-uroot -p123456
Warning: Using apassword on the command line interface can be insecure.
Welcome to the MySQLmonitor. Commands end with ; or \g.
Your MySQL connection idis 81
Server version: 5.6.34Source distribution
Copyright (c) 2000,2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registeredtrademark of Oracle Corporation and/or its
affiliates. Other namesmay be trademarks of their respective
owners.
Type 'help;' or '\h' forhelp. Type '\c' to clear the current input statement.
mysql> selectuser,host from mysql.user;
+-----------+--------------------------+
| user | host |
+-----------+--------------------------+
| root | 127.0.0.1 |
| wordpress |172.16.1.0/255.255.255.0 |
| root | ::1 |
| | localhost |
| root | localhost |
| | web01 |
| root | web01 |
+-----------+--------------------------+
7 rows in set (0.00 sec)
欢迎加入qq群:202932777,一起交流,一起进步!!!
- mysql数据库中管理员用户(root@localhost)被误删除,怎么恢复
- mysql数据库root用户恢复
- mysql root用户被删除掉了 如何恢复
- Linux root用户不小心删除了,怎么恢复
- MySQL数据库localhost的root用户登陆遭遇失败
- MySql中添加用户,新建数据库,用户授权,删除用户,修改密码,root密码丢失
- root用户被删除怎么进phpmyadmin
- root用户连接mysql数据库出错 1045 access denied for user 'root'@'localhost' using password yes
- 解决Mysql 5.1误删除root用户
- MySQL root用户被删除解决办法
- 【XAMPP】mysql数据库忘记管理员root密码
- 在phpmyadmin中误删root用户!怎么恢复?
- mysql-noinstall误删除root@%的恢复操作
- MYSQL ROOT 账户 误删除后的恢复办法
- MYSQL数据库误删除恢复笔记收藏
- MYSQL数据库误删除恢复笔记收藏
- 详解Mysql数据库恢复误删除数据
- mysql不小心删除root恢复
- struts2值栈一些问题
- 两种方式综合请求网络数据
- <转载>java(37):java中length,length(),size()区别
- Codeforces 897C(递归)
- 小白使用react---ajax请求后的数据在另一个页面显示
- mysql数据库中管理员用户(root@localhost)被误删除,怎么恢复
- 单链表上机实验
- 封装opencv的函数成dll,独立调用
- 【Scikit-Learn 中文文档】聚类
- 从最大子数组和问题详尽贪心算法策略
- N的阶乘末尾有多少个0 51Nod
- Android使用自定义控件实现无限轮播
- hdoj-1570A C
- 可持久化Treap(范浩强Treap)