Secure existing MySQL installation

secure-mysql-installation
MySQL is a free, easy-to-use database server that supports multiple databases and tables, and allows clients to query them with SQL. This cheat-sheet shows how to secure MySQL in a few simple steps.

Change MySQL root password

First step to secure MySQL is changing the database superuser password, which is empty by default:

mysql> UPDATE mysql.user SET Password=PASSWORD('pa$$w0rD') WHERE User='root'; Remove unneeded databases and users

Next, remove test database:

mysql> DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'; mysql> DROP DATABASE test;

and users:

mysql> DELETE FROM mysql.user WHERE User='root' AND Host != 'localhost'; mysql> DELETE FROM mysql.user WHERE user = '';

Finally, reload MySQL privilege information to make above changes to take effect:

mysql> FLUSH PRIVILEGES; Improve local security

MySQL config file contains several directives that can help to avoid some types of attacks. Open it and change the following values in [mysqld] section:

bind-address=127.0.0.1 local-infile=0 # avoid some Denial of Service attacks max_user_connections=256 max_connect_error=4

bind-address
Make MySQL to listen for TCP/IP connections only locally on the loop-back interface.

local-infile
Prevents against unauthorized reading from local files, useful to avoid SQL injection attacks.

max_user_connections
The maximum number of simultaneous connections allowed for a single user

max_connect_error
Block a host after this many unsuccessful connection attempts. This is especially helpful against a dictionary-based password attack. You can unblock blocked hosts with the FLUSH HOSTS statement.

Install a database firewall

GreenSQL is an Open Source database firewall used to protect databases from SQL injection attacks. It works as a proxy and has built-in support for MySQL. The logic is based on evaluation of SQL commands using a risk scoring matrix as well as blocking known db administrative commands (DROP, CREATE, etc). GreenSQL provides MySQL database security solution

Related Posts:

Sursa
2009-12-17 16:13:28



Comenteaza





Ultimele 25 posturi adăugate

15:02:24 —» Путепроводные Заметки
08:53:18 —» Путепроводные Заметки
20:09:05 —» Путепроводные Заметки
14:12:49 —» Путепроводные Заметки
07:12:00RĂUL SE FACE, BINELE SE CREEAZĂ —» Leo Butnaru
17:02:12 —» Путепроводные Заметки
16:51:37Balul Mascat de la „Casa Sorelui” – un adevărat spectacol de bucurie! —» Asociaţia Obştească "Demos"
16:25:42Finalizarea procesului de selecție a furnizorilor pentru programul de susținere a tinerilor antreprenori —» Asociaţia Obştească "Demos"
09:25:00I Wish… —» Александр Ищенко - Размышления
06:33:00ÎN GRĂDINA DOMNULUI —» Leo Butnaru
22:55:45 —» Путепроводные Заметки
15:47:15 —» Путепроводные Заметки
14:20:36 —» Путепроводные Заметки
06:59:00STRICTUL NECESAR —» Leo Butnaru
04:40:37 —» Путепроводные Заметки
22:40:20 —» Путепроводные Заметки
17:37:45 —» Путепроводные Заметки
14:57:07 —» Путепроводные Заметки
07:04:00DIN STRICTUL NECESAR —» Leo Butnaru
19:58:25Sfinții Vechiului Testament – Vasile Filat —» Moldova Creștină
18:57:55Folclorul ce se duce —» Biblioteca de Arte 'Tudor Arghezi'
13:43:18BANZAI —» Andrei LANGA. Blogul personal
13:32:00Top 10 fotbaliști moldoveni în 2024 —» Sandu GRECU
08:27:05Unde dispar prietenii noștri!? —» Sergiu Mocanu
08:21:00DIN LEOLOGISME —» Leo Butnaru