Home > Database > Mysql Tutorial > Improving the security of MySQL database (4)

Improving the security of MySQL database (4)

巴扎黑
Release: 2017-04-28 16:54:51
Original
1541 people have browsed it

Talk about how to improve the security of the MySQL database from a network perspective

When connecting the MySQL database to the network, some special security issues arise.

It's not a bad idea to create a user specifically for network connections. This will grant them the necessary, minimal permissions, thereby not granting the user permissions such as DROP, ALTER, or CREATE permissions. We might grant SELECT permission only in the type table and INSERT permission only in the order table. Additionally, this is an example of how to apply the principle of least privilege.

Tip: In the previous content, we talked about PHP's addslashes() function and stripslashes() function to remove any characters that may cause problems. It is very important to remember to do this and perform a general data cleanup before sending any data to the MySQL database. You may remember that we used the doubleval() function to check whether numeric data is actually numeric data. One mistake we often make is forgetting about it - people often remember to use addslashes() but forget to check for numeric data.

All data from users should be checked frequently. Even if an HTML form consists of option boxes and buttons, someone may still be able to access the script by trying to modify the URL. Additionally, the size of user data should be checked.

If the password or confidential data entered by the user needs to be saved in the database, please note that if it is not SSL (Secure Sockets Layer, encrypted socket layer), these data will be passed from the browser to the browser in plain text server. Regarding the usage of SSL, we will talk about it later.


Remove risky components

The default configuration of MySQL database has some unnecessary components, you can Consider the following suggestions:

1. Disable the LOAD DATA LOCAL INFILE command

This command allows users to read local files and even access files on other operating systems, which may help attackers collect important information and exploit application vulnerabilities to hack into your database. What you need to do is insert set-variable=local-infile=0 into the my.cnf file of the MySQL database to disable this directive.

2. Delete the test database

There is a default "test" database for testing purposes. Since this database is a security risk and can be accessed by anonymous users, you should use the mysql> DROP database test; command to clear it as soon as possible.

3. Delete the history file

MySQL server has a history file, which can help you find the problem when the installation goes wrong. History files contain sensitive information, such as passwords. If this information is obtained by an attacker, it will bring huge security risks to your database. After the installation is successful, the history file is of no use, so you can use the cat /dev/null > ~/.mysql_history command to delete the contents of the file.

[Related recommendations]

Improve the security of MySQL database (1)

Improve the security of MySQL database (2)

Improve the security of MySQL database Security (3)

The above is the detailed content of Improving the security of MySQL database (4). For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template