MySQL deletes anonymous users to ensure login security
Many MySQL programs use the anonymous logon function. After installing MySQL, you can log on to the database.
This is basically nothing for MySQL, but this login method is definitely not available when we want to deploy the database! Think about it. If your database can be accessed at will, I think you will receive a call in the middle of the night, saying there is a problem with the data!
The following describes how to delete Anonymous Users:
First, run the command to enter the database.
[Root @ localhost raul] # mysql-u root-p
Enter password:
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 3
Server version: 5.1.73 Source distribution
Copyright (c) 2000,201 3, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.
Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.
Switch the database to mysql.
Mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with-
Database changed
Before deleting a database, we should first check the database user table to see the existence of the user.
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)
As we can see, some rows in the user column are empty. This is the anonymous user ~! In this step, we have found an anonymous user. The remaining operation is to delete the user and ensure login security.
Mysql> delete from user where user = '';
Query OK, 2 rows affected (0.00 sec)
At this time, the execution status of mysql shows that we have deleted two rows of data, and then executed the query command to check whether the deletion was 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)
OK! Deleted successfully
-------------------------------------- Split line --------------------------------------
Install MySQL in Ubuntu 14.04
MySQL authoritative guide (original book version 2nd) Clear Chinese scan PDF
Ubuntu 14.04 LTS install LNMP Nginx \ PHP5 (PHP-FPM) \ MySQL
Build a MySQL Master/Slave server in Ubuntu 14.04
Build a highly available distributed MySQL cluster using Ubuntu 12.04 LTS
Install MySQL5.6 and Python-MySQLdb in the source code of Ubuntu 12.04
MySQL-5.5.38 universal binary Installation
-------------------------------------- Split line --------------------------------------
This article permanently updates the link address: