標籤:切換資料庫 情況 mes server mon 查看 ade NPU font
首先使用命令進入資料庫
[[email protected] raul]# mysql -u root -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.1.73 Source distributionCopyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
然後切換資料庫,進入我們須要操作的資料庫mysql
mysql> use mysqlReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changed
刪除之前我們先查看一下資料庫的使用者表,看看使用者的存在情況
mysql> select user, host from user;+------+-----------------------+| user | host |+------+-----------------------+| root | 127.0.0.1 || | localhost || root | localhost || | localhost.localdomain || root | localhost.localdomain |+------+-----------------------+5 rows in set (0.00 sec)
我們看到啦,在user這一列有的行是空的。這就是那個匿名使用者啦~。在這一步我們已經找到匿名使用者啦,剩下的操作就是刪除掉這個使用者,保證登入安全
mysql> delete from user where user=‘‘;Query OK, 2 rows affected (0.00 sec)
此時mysql啟動並執行狀態顯示我們刪除了兩行資料,然後運行一邊查詢命令,確認一下是不是真的刪除成功啦?
mysql> select user, host from user;+------+-----------------------+| user | host |+------+-----------------------+| root | 127.0.0.1 || root | localhost || root | localhost.localdomain |+------+-----------------------+3 rows in set (0.00 sec)
mysql刪除匿名使用者