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:24:24🎊 15 ani de activitate ai S.A. „Loteria Națională a Moldovei" —» Sandu GRECU
12:58:44Am desemnat câștigătorul premiului de 6600 de lei oferit de Clubul Premier Football 💥🏆🔝 —» Sandu GRECU
09:07:43TÜV Austria își extinde prezența în Republica Moldova: Standarde internaționale pentru creșterea competitivității economice 💫 —» Sandu GRECU
13:45:50Efros la Londra, acasă la Borsetca. Agenție de impresariat împreună cu Plahotniuc. Banii din transferuri 🔥🔥🔥 —» Sandu GRECU
12:13:34Moldova, prezentă la CMB în Erevan —» Fine Wine
05:30:37INTERVIU CU UN CORESPONDENT... NEVĂZUT —» Leo Butnaru
15:12:02🔔 Chișinăul va găzdui evenimentul la nivel înalt EU-Moldova Investment Conference pe 4 iunie 2026 —» Sandu GRECU
07:27:39INVIDIA, URA —» Leo Butnaru
06:59:25Agricultura 5.0 în nordul țării: Tinerii au testat tehnologiile viitorului la Târgul „Viitorul e AgriCOOL” din Corlăteni 🦾 —» Sandu GRECU
10:06:48Radacini lansează Long Charmat Rosé de Noirs —» Fine Wine
08:32:32Vinăria din Vale: rebranding la Motive; Feteasca Regală intră în scenă —» Fine Wine
04:56:02UN INTERVIU —» Leo Butnaru
09:28:35DIN PASIENȚE —» Leo Butnaru
08:35:53Interviu RomStoria: Primul student rom la Sydney —» Curaj.TV | Media alternativă
13:51:31APROAPE DE PEDAGOGIE —» Leo Butnaru
10:18:33Crisecco apare în variantă nouă —» Fine Wine
10:03:46Lansarea cărții ilustrate ”Legenda Bradului” de autoarea Cristina Rusu Trandafir —» Biblioteca de Arte 'Tudor Arghezi'
12:18:14Vasile Costiuc, acid ca niciodată! Atletismul și dubinca. Curățenie olimpică. Lupta cu Viorel 🔥🔥🔥 —» Sandu GRECU
10:02:22Probabil, cea mai bună Floricica din Moldova —» Fine Wine
12:18:07Fautor lansează primul său spumant – Bliss —» Fine Wine
10:15:38Călărași Divin intră pe piața vinurilor  —» Fine Wine
13:26:00Anul – 2026 – anul evaluării bibliotecilor publice —» Biblioteca Publică or.Rîşcani
05:13:03O EDIȚIE ROMÂNO ITALIANĂ —» Leo Butnaru
19:49:00Dragostea în faptă —» adevaruri biblice
05:10:06YES-EU —» Leo Butnaru