Mysql – How to properly secure MySQL database

encryptionMySQLmysql-5.1Security

We have a web application based on the famous triad apache + php + mysql which we sell to our customers and gets installed on their servers.

Currently, we are using MySQL 5.1.41 which has only a single user registered, root, with is password and access allowed only from localhost.

The problem is, if someone creates its own mysql installation, and then copies our database from its original location to that independent installation, s/he would be able to access its content.

Is there a way to prevent also this kind of improper access to our webapp database? Can it be encorder MySQL-side or must it be something in our own application?

Best Answer

I normally do not endorse any one specific product, but in this case I will make an exception.

I have personally evaluated a product called Gazzang. It can encrypt data in such a way that when transported to another server, the data is unreadable unless the encryption key is copied and verified on that external server. I have tried this and copied /var/lib/mysql on another server that did not have the encryption key. The only SQL command that worked with the database encrypted is SHOW DATABASES;. Nothing else worked.

There are some hoops to jump through to get an entire /var/lib/mysql folder encrypted. Once done, you never have to worry about data encryption. Perhaps you could start like this:

  • Installation MySQL on a DB Server
  • Apply Gazzang's ezncrypt program against the empty /var/lib/mysql
  • Load a mysqldump into it

The beautiful part of my evaluation was that the MySQL data was fully accessible by standard DB Connections. Gazzang does not shield normal access protocols. You must take up responsibility for securing passwords:

EPILOGUE

As for the physical data itself, this worked during the 30-day evaluation. Please evaluate it for yourself. I will leave it to you to investigate production case studies on Gazzang.

UPDATE 2015-09-29 12:26 EDT

Cloudera purchased and deprecated Gazzang.

Cloudera Data Encryption is still available.