Recover MySQL from files

This is how I recovered my databases from a HD crash using Mac OS X. These included both MyISAM and InnoDB tables.

  1. Get the files, typically from a backup or booting into your machine/server in recovery mode, usually located @ /var/lib/mysql
  2. Read (if you own this file) mysql_upgrade_info, so you see which mysql version created the files.
  3. Install the same version in your machine. If needed, uninstall whatever exists (if you don’t need it, of course):
brew remove mysql
  1. Install the closest mysql version to that you found in mysql_upgrade_info (or whatever you guess is the version). See the available formulas and do it:
brew search mysql
brew install mysql@5.5
  1. I installed myself version 5.5, which is the one I needed.
  2. Now locate the place where the local files reside, typically @ /usr/local/var/mysql
  3. Zip this folder as a backup measure and remove all of its contents.
  4. Move inside all the files and folders you got in step 1.
  5. Launch mysql:
/usr/local/opt/mysql@5.5/bin/mysql.server start
  1. Connect and mysqldump whatever you need.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s