SurlyJake Blog

What Not to Do in MySQL... And How to Pick Up the Pieces

| Comments

note to self… do NOT kill mysql processes from phpmyadmin’s control panel and force mysql to quit. Bad things happen. In this case, mysql wouldnt start again. InnoDB’s indexes, binary logs, etc. were all out of sync. The 20 page log explaining all the ways the DB couldn’t start is located in the DB’s data dir, which in my case was in /dbdisks/.err.

To tell mysql to pick up the messy pieces and throw up whats left of your data, edit or create /etc/my.cnf and add this little line to the “[mysqld]” section:

innodb_force_recovery = 3

The command is talked aboot here the number is btw 1 and 6. bigger the number, the more drastic and desperate it is. I tried 4, and it pulled the tables with no data. 1 gave me nothing. but 3 let me start and mysqldump my database.

mysqldump -u root -p <dbname > /path/to/.sql/file

so once the dump was completed, i moved the db data directory, commented out the “innodb_force_recovery” line, and restarted the computer. At restart the db data dir was re-created by mysql. fresh and clean. this deletes EVERYTHING. even users. re-import the data with

mysql -u root <dbname> < /path/to/.sql/file

go ahead and create the users needed, and set root password again. There you go.

Comments