Moving the MySQL data dir into an encrypted location

1

I'm trying to move the mysql datadir on my Ubuntu 10.04 to an encrypted location.

I tried a naive approach of:

  1. setting up the encrypted private directory ( https://help.ubuntu.com/community/EncryptedPrivateDirectory )
  2. sudo stop mysql
  3. changing the datadir to ~/Private/mysql under [mysqld] in the my.cnf
  4. sudo mv /var/lib/mysql ~/Private/ sudo start
  5. sudo start mysql

Alas, not only did mysql not start, but I got a black screen with some text outputs ("fsck" caught my eye, but not much more) and a total freeze of the machine. After a hard reset, the entire user account won't log in, and I had to create a new one for now. By the way, even after moving the datadir back and getting mysql to work again (all from the secondary account), the primary account still won't log in, with the black screen with text message showing for about half a second and then throwing me back to the login screen.

Any thoughts on how to get the datadir into an encrypted location the "right way"?

(And what could possibly have screwed up the account so badly..)

GJ.

Posted 2010-08-23T20:07:59.267

Reputation: 8 151

1"a total freeze of the machine" makes this sounds like a lot more than just an encrypted directory and/or mysql problem to me. – Jarvin – 2010-08-23T20:23:48.443

Answers

0

eCryptFS encrypted directories (when used like that) are only accessible by the users that mount them, and of course MySQL doesn't run as your user...

You might want to look into mounting an eCryptFS from fstab or maybe using a LUKS encrypted partition. Of course, you'll have to enter a passphrase at every boot then...

JanC

Posted 2010-08-23T20:07:59.267

Reputation: 1 125