My old Raspberry Pi 2’s sdcard fell victim to sdcard corruption.  I wasn’t able to dump my MySQL tables cleanly because the database was unable to start by the time I realized what was going on.

I’ve restored what I could of my wonderful little blog, but there was data loss during the migration to a new sdcard.  That’s why things look a bit different.

Lessons Learned

What doesn’t work

If you’re moving MySQL tables, do not simply copy the directories from /var/lib/mysql

Worse yet, if you’re using InnoDB, you’ll be missing the /var/lib/mysql/ib* files that InnoDB requires.

MySQL is very picky and if it senses anything is amiss it will simply throw its hands in the air and give up.

What works

Ideally, you need to dump your databases while connected to the MySQL server with something like this:

mysql -u root -p wordpress > wordpress.sql

This dumps the entire database into an SQL script you can re-import on your new database.  You suck it back up with the same syntax:

mysql -u root -p wordpress < wordpress.sql