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?

link|improve this question

feedback

1 Answer

up vote 1 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.

link|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
feedback

Your Answer

 
or
required, but never shown

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