NOTE: The steps described below are not intended to be vendors approved fix practice. It is basically dirty hack and may lead to total MySQL data loss!
Symptoms:
- Most likely there was cold restart on VPS prior the issue appeared
- MySQL not starting
-
MySQL log
/var/lib/mysql/hostname.err
is full of errors related to InnoDB and even pieces of core dump code
Solution:
- Ensure MySQL stopped, if not then stop it.
-
Backup ENTIRE /var/lib/mysql directory to somewhere
- Enable InnoDB forcing recovery placing the line
innodb_force_recovery = 4 to /etc/my.cnf
- Start MySQL (if not starting you can play with numbers from 1 to 6 in above line)
- Do initial checks via
mysqlcheck -A --auto-repair
, (don't panic if it cannot finish full checks)
- Do the full dump of DBs:
mysqldump -A > dump.sql
- Stop MySQL
- Comment out the
innodb_force_recovery in /etc/my.cnf
- Remove
/var/lib/mysql/ib*
- VERY DANGEROUS! Remove all *.idb files inside of mysql directory:
find /var/lib/mysql -type f -name "*.ibd" -delete
- Start MySQL
- Fill the MySQL with dump created in step 6:
mysql < dump.sql
- If the dump will stop with error "cannot create database" then drop that database in mysql and repeat filling the dump.
- If the dump has errors regarding 'duplicate entry for key' you will need to run the restore with --force
In ideal conditions it will fix problems.
|