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 recently backed up my entire laptop hard drive with SuperDuper and reinstalled Snow Leopard. Because I made an image clone, I was able to restore all my files without losing any data. Go hard drive cloning.

However, the one thing I forgot to do was to do a dump of all my MySQL databases. Eek. Because of the nature of MySQL's storage, I can't just drag and drop the databases and tables—all the data is locked up in the server.

When I mount the cloned image I can navigate to /Volumes/laptop/usr/local/mysql/var (since I had installed MySQL to /usr/local/mysql) and I can see all my databases listed as directories with random files inside, which seems promising.

What should I do to restore all those databases I forgot to dump? Is there a way to restore the var/ folder to my new, fresh installation of MySQL and (hopefully) maintain all the users and privileges? Can I just copy that directory and have everything work?

share|improve this question
up vote 2 down vote accepted

Disclaimer: I can't guarantee that this works for you too, it did for me.

I've done similar restorations (under Windows, though) by simply copying the files (the whole /usr/local/mysql directory...shouldn't that be under /var/mysql anyway?). Of course you'll need to stop the MySQL daemon and restart if after you're done.

Also, check the file permissions, just in case that something has changed.

share|improve this answer
Excellent. A variation of your idea worked. All the MySQL data was in /usr/local/mysql/var, so I copied the original folder over to my new installation (not the whole /usr/local/mysql directory… just the var) and I made sure the mysql user could access it (sudo chown -R mysql /usr/local/mysql/var). The trickiest part was telling MySQL to look at it. Once I ran the install_db script (/usr/local/mysql/bin/mysql_install_db --user=_mysql), everything worked perfectly. Amazing! – Andrew Jul 21 '10 at 14:19

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.