Many MySQL programs come with the ability to log on anonymously. After you've just installed MySQL, you can log in to the database.
This is basically nothing to use MySQL, but if we want to deploy the database, this type of login can never exist! Imagine, if your database can be entered casually, I think you will be in the middle of the night to receive a call, said the data is a problem!
Here's how to delete anonymous users:
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, in the User this column has a row is 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 MySQL execution shows that we have deleted two rows of data, and then execute one side of the query command, to confirm that the deletion is really successful AH
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)
Ok! It's been successfully deleted.
"MySQL" mysql delete anonymous user, ensure login security