刪除匿名用戶
在MySQL剛剛被安裝後,存在用戶名、密碼為空的用戶。這使得數據庫服務器有無需密碼被登錄的可能性。為消除隱患,將匿名用戶刪除。
[root@sample ~]# mysql -u root -p ← 通過密碼用root登錄
Enter password: ← 在這裡輸入密碼
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7 to server version: 4.1.20
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> select user,host from mysql.user; ← 查看用戶信息
+------+----------------------------+ www.2cto.com
| user | host |
+------+----------------------------+
| | localhost |
| root | localhost |
| | sample.centospub.com |
| root | sample.centospub.com |
+------+----------------------------+
4 rows in set (0.02 sec)
mysql> delete from mysql.user where user=''; ← 刪除匿名用戶
Query OK, 2 rows affected (0.17 sec)
mysql> select user,host from mysql.user; ← 查看用戶信息
+------+----------------------------+
| user | host |
+------+----------------------------+
| root | localhost |
| root | sample.centospub.com |
+------+----------------------------+
作者 亦夢亦真