"MySQL" mysql delete anonymous user, ensure login security

Source: Internet
Author: User

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

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.