Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
"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...

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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