FULL RECOVERY!!!--I can't believe it.
Kept getting database errors re: timing out and other issues due to knowing nothing about DBs...so did a lot of experimenting. I used all the help in this string plus heaps of reading up on mySQL recovery, permissions for mySQL folders and files, and mySQL DB users/permissions. I'm not 100% sure what made the difference in the end.
Here is roughly how the fix unfolded, not too sure if this was the order or if I missed anything.
- Fresh install of Unbuntu 15.04 on second VPS because that is what I was upgrading to when I crashed. I am clueless if this mattered but I thought the less variables the better.
- Installed mySQL
- I think I added innodb_force_recovery = 6 under [mysqld] to mysqld.cnf. Struggled knowing which .cnf file to use because it should have been my.cnf? But got errors with that one.
- I probably forgot to "service mysql restart" after changing .cnf file...so remember to do this.
- I think I copied over the recovered moodle folder with .frm files and the recovered ibdata1 into /var/lib/mysql. I'm pretty sure I didn't copy over the lof files..maybe even deleted them?
- Don't think I did this but may have also put innodb_log_file_size=XXM, with the "XX" as the size in mb of the original log files I think?
- To make sure the permissions were OK I temporarily made all of the files and folders 0777 with mysql as group/owner
- Kept having trouble with these:
- sudo mysql_upgrade -u root -p --force
- mysqldump -u root -p moodle > moodlefixed.sql
- So did this and the dump worked.
mysql> create user 'PUTUSERNAMEHERE'@'localhost' IDENTIFIED BY 'PUTPASSWORDHERE';
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO PUTUSERNAMEHERE@localhost IDENTIFIED BY 'PUTPASSWORDHERE';
Take home point to avoid spending 50 hrs on this (but learing a lot along the way): you need to back up moodle, moodledata, and you need to backup the database /var/lib/mysql properly by mysqldump:
mysqldump -u root --p moodle > /moodlebackup.sql