MySQL security question tips _ MySQL

Source: Internet
Author: User
A bit of knowledge about MySQL security issues bitsCN.com two days ago when I was helping a friend sort out his home page space, I found that some questions about MySQL may be ignored: We know that after installing MySQL, it automatically creates a root user and an anonymous user, and the initial password is empty. for the former, many references will remind you to set a password in time, ignoring the latter is probably because the latter is set to be used only on the local machine by default.
However, if your MySQL database is to be provided to the Web server for database services, the cost of ignoring this anonymous user may be quite high, because in the default settings, this anonymous user has almost the same permissions as root on localhost. at this time, if your customer has the permission to upload script files and script files, you can perform MySQL database operations (for example, allow MySQL php operations) you may have changed your MySQL account:
When I helped my friend sort out his home page space today, I tried to write a simple php file for SQL statement execution and upload it. I tried to leave the user and password in the connection word empty, host = localhost. The result shows that my SQL statement can be executed, so select * from MySQL is executed. the user checks the user's permissions and finds that the user has a high permission on localhost, even grant_priv. (during the inspection, the user will find that there are two lines of usernames and passwords with blank passwords under the root user, however, if the permissions are y, the anonymous user's local and remote permissions are set)
So I tried to use this php page to create a new user and grant him higher permissions, in this way, I can use this new user to connect to the MySQL server of this website through the MySQL client of my local machine, and manage the MySQL server of this website with the management permissions of this new user, I can see that I can easily obtain in-depth database operations. how can I put sensitive information on my friend's homepage space into this MySQL server?
Suggestions for improvement:
1. After MySQL is installed, it not only changes the password of the root user, but also the password of the anonymous user. the method is similar to changing the root password:
MySQL> UPDATE user set password = PASSWORD ('yournewpassword') where user = '';
MySQL> flush privileges;
2. if not necessary, delete this anonymous user so that all users must provide a user name to use MySQL. even if a problem occurs after the day, it is easy to find the source of the problem.
3. except for the root user, other users, including anonymous users (if the user is not deleted), should not have the grant permission to prevent the spread of uncontrolled management permissions.
4. assign the updatedeletealertcreatedrop permission to a specific database. in particular, avoid having common users the permission to operate the MySQL database, otherwise, your system settings may be replaced.
5. check the MySQL. user table and cancel unnecessary shutdown_priv, reload_priv, process_priv, and File_priv permissions. these permissions may leak more server information including non-MySQL information.
6. if you do not want your users to use the MySQL database, reset or compile your php when providing script languages such as php, and cancel their default support for MySQL. BitsCN.com

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.