mysql資料庫中管理員使用者([email protected])被誤
正常狀態:
[[email protected] 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 [email protected];
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)
解決:
需要使用[email protected]使用者登入系統(無密碼),再建立[email protected]
[[email protected] 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 [email protected] 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
恢復正常
[[email protected] 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,一起交流,一起進步!!!