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

10:45:10Elfrida Koroliova: prin labirintul pasiunilor —» Biblioteca de Arte 'Tudor Arghezi'
14:23:00Stix —» Andrei LANGA. Blogul personal
17:12:43Razie cu scandal filmată de Activistul buzoian —» Curaj.TV | Media alternativă
07:01:00JURNALUL CA MEMORIE —» Leo Butnaru
13:53:00Covor —» Andrei LANGA. Blogul personal
13:53:00Covor —» Andrei LANGA. Blogul personal
07:25:10La Steaua care-a Răsărit — poezie, tradiție și lumină de Crăciun la bibliotecă —» BPR Ungheni's Blog
06:58:00DIN ISTORIA AVANGARDISMULUI EUROPEAN —» Leo Butnaru
08:42:00STRICTUL NECESAR —» Leo Butnaru
17:04:34În sfârșit, știu ce vreau să mă fac când voi fi mare! —» APort | "Pentru un român care știe citi, cel mai greu lucru e să nu scrie." I.L. Carag
11:22:00argivă 2019 —» Leo Butnaru
07:47:00POEZIA FRANCEZĂ —» Leo Butnaru
07:13:00DIN COSMOGRAME —» Leo Butnaru
07:32:00DINTR-O ANTOLOGIE RECENTĂ —» Leo Butnaru
21:49:14Fără Titlu —» Путепроводные Заметки
19:24:04Fără Titlu —» Путепроводные Заметки
17:21:11Fără Titlu —» Путепроводные Заметки
07:06:00EXIST, DECI RĂSPUND —» Leo Butnaru
19:22:06Fără Titlu —» Путепроводные Заметки
15:58:07Fără Titlu —» Путепроводные Заметки
07:40:00LEOLOGISMELE ȘI TRADUCEREA —» Leo Butnaru
20:51:57Fără Titlu —» Путепроводные Заметки
18:01:47Fără Titlu —» Путепроводные Заметки
09:07:08A fost lansată noua ediție a Fine Wine Guide —» Fine Wine
09:02:00DIN POEZIA LUMII —» Leo Butnaru