[MySQL] MySQL deletes anonymous users to ensure login security

Source: Internet
Author: User

[MySQL] 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 -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.
Switch the database to 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 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.