刪除匿名使用者
在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.20Type '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 |+------+----------------------------+ 作者 亦夢亦真