5 Essential Steps to Hardening Your MySQL Database

By Kyle Rankin

Linode
Linode
Aug 23, 2017 · 8 min read
Image for post
Image for post
[mysqladmin]user = rootpassword = yourpassword
$ sudo chown root:root /root/.my.cnf$ sudo chmod 0600 /root/.my.cnf
> SELECT Host, User FROM mysql.user;+ — — — — — — — — — — — — + — — — -+| Host | User |+ — — — — — — — — — — — — + — — — -+| 127.0.0.1 | root || ::1 | root || localhost | || localhost | root |+ — — — — — — — — — — — — + — — — -+4 rows in set (0.00 sec)
> drop user “”@”localhost”;> flush privileges;
> grant all privileges on mydb.* to someuser@”localhost” identified by ‘astrongpassword’;> flush privileges;
> grant select privileges on mydb.* to someuser@”localhost” identified by ‘astrongpassword’;> flush privileges;
> grant all privileges on mydb.* to someuser@”%” identified by ‘astrongpassword’;> flush privileges;
> grant all privileges on mydb.* to someuser@10.0.1.0/255.255.255.0 identified by ‘astrongpassword’;> flush privileges;
[mysqld]ssl-ca=/path/to/ca.crtssl-cert=/path/to/server.crtssl-key=/path/to/server.key
> grant all privileges on mydb.* to someuser@10.0.1.0/255.255.255.0 identified by ‘astrongpassword’ REQUIRE SSL;> flush privileges;


Linode Cube

We’re covering everything from tech news and industry…

Linode

Written by

Linode

Cloud Hosting for You. Sign up today and take control of your own server! Contact us via ticket or email for all support inquiries: https://www.linode.com/contact

Linode Cube

We’re covering everything from tech news and industry happenings to event recaps and general tips.

Linode

Written by

Linode

Cloud Hosting for You. Sign up today and take control of your own server! Contact us via ticket or email for all support inquiries: https://www.linode.com/contact

Linode Cube

We’re covering everything from tech news and industry happenings to event recaps and general tips.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store