First Use the command to enter the database
[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), +, Oracle and/or its a Ffiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names trademarks of their respectiveowners. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
Then switch the database into the database we need to operate 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
Before we delete, we'll look at the user table of the database to see if the user exists.
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)
We see that the rows in the user column are empty. This is the anonymous user. In this step we have found anonymous users, the rest of the operation is to delete the user, to ensure that the login security
mysql> Delete from user where user= '; Query OK, 2 rows Affected (0.00 sec)
At this point, the status of the MySQL run shows that we have deleted two rows of data, and then run the query command, confirm that the deletion is really successful?
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 Delete anonymous user