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..)

  • 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 Aug 23 '10 at 20:23

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...

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.