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

17:44:1550 ans déjà —» APort | "Pentru un român care știe citi, cel mai greu lucru e să nu scrie." I.L. Carag
12:23:00Espolón —» Andrei LANGA. Blogul personal
05:47:04INTERSECȚII —» Leo Butnaru
14:24:00te-am visat (nu). —» Ghiocika
14:16:00Și iar. Noroc. —» Ghiocika
13:11:02Lectura a fost sărbătorită la Ungheni printr-un eveniment inedit – Speed Reading Café —» BPR Ungheni's Blog
07:51:00VERNISAJ —» Leo Butnaru
09:38:00Eter —» Andrei LANGA. Blogul personal
09:38:00Eter —» Andrei LANGA. Blogul personal
07:57:00NINGE —» Leo Butnaru
17:06:35Romstoria: Romii boemieni —» Curaj.TV | Media alternativă
13:33:20Risc de embargo ucrainean la vinurile moldovenești? —» Fine Wine
15:20:00JURNALUL ÎN CONTINUARE... —» Leo Butnaru
19:41:00...de scris —» Mihai Dohot - impresii şi opinii personale
09:05:00DIN STRICTUL NECESAR —» Leo Butnaru
06:51:00Resetări —» Andrei LANGA. Blogul personal
06:51:00Resetări —» Andrei LANGA. Blogul personal
06:51:00Resetări —» Andrei LANGA. Blogul personal
05:57:13DIN COSMOGRAME —» Leo Butnaru
22:40:28La 12 „trecute fix” —» Curaj.TV | Media alternativă
22:40:28La 12 „trecute fix” —» Curaj.TV | Media alternativă
08:14:00DIN REVISTA TINERILOR —» Leo Butnaru
09:01:09Nou: Sauvignon Blanc BIO de la Gogu Winery —» Fine Wine
07:29:00DIN STRICTUL NECESAR —» Leo Butnaru
13:48:09Eugenia Botnaru, actriță de teatru și film —» Biblioteca de Arte 'Tudor Arghezi'