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

06:15:00JURNALUL CA MEMORIE —» Leo Butnaru
06:41:00DIN POEZIA UNIVERSALĂ —» Leo Butnaru
07:09:00DIN STRICTUL NECESAR —» Leo Butnaru
11:13:44Moldova (+ Georgia) și jocurile marilor puteri —» Curaj.TV | Media alternativă
06:03:17DIN YES-EURI —» Leo Butnaru
13:07:33Fără Titlu —» Путепроводные Заметки
06:31:00PĂZITOR ȘI SCRIITOR —» Leo Butnaru
20:45:20Fără Titlu —» Путепроводные Заметки
19:26:07Fără Titlu —» Путепроводные Заметки
18:04:08Fără Titlu —» Путепроводные Заметки
16:30:53Fără Titlu —» Путепроводные Заметки
14:02:19Fără Titlu —» Путепроводные Заметки
06:18:00DIN YES-EURI —» Leo Butnaru
00:39:44Fără Titlu —» Путепроводные Заметки
23:18:25Fără Titlu —» Путепроводные Заметки
22:53:06O plimbare prin Capitala Neamului —» APort | "Pentru un român care știe citi, cel mai greu lucru e să nu scrie." I.L. Carag
18:29:28Fără Titlu —» Путепроводные Заметки
16:44:39Fără Titlu —» Путепроводные Заметки
06:51:05DIN STRICTL NECESAR —» Leo Butnaru
02:12:33Fără Titlu —» Путепроводные Заметки
23:17:51Fără Titlu —» Путепроводные Заметки
19:46:26Peter Heather, John Rapley – Why Empires Fall —» APort | "Pentru un român care știe citi, cel mai greu lucru e să nu scrie." I.L. Carag
19:33:08Fără Titlu —» Путепроводные Заметки
17:57:48Fără Titlu —» Путепроводные Заметки
14:36:11Fără Titlu —» Путепроводные Заметки