MySQL Recovery
Posted by Max Dunn Mon, 05 Mar 2007 16:57:00 GMT
We had a bad crash yesterday on our MySQL 5.0.22 database. Our guess is that we ran out of hard disk space during a large transaction and the database somehow got corrupted. Worse, restarting MySQL didn’t clear the error, but continued to have the problem. Luckily, we could still read from the database so we were able to do a current backup which allowed us to recreate the database and re-import the data. Here are the steps we used:
- In my.conf use:
innodb_force_recovery = 6
(or lower) to bring the database up.
(See http://www.mysql.org/doc/refman/5.1/en/forcing-recovery.html) - Dump the tables. For example. to dump the ‘maxwiki’ table use:
mysqldump - mysqldump --database maxwiki -u (username) -p (password) > maxwiki.sql
Repeat for all other tables - Shut down the database
- Move all files out of /usr/bin/mysql and put elsewhere
- Re-init with:
mysqld_safe --user=mysql mysql_install_db --user=mysql mysqladmin -u (username) password '(password)'
- Reload all the tables from the sql files
- Reset the users
Hey Max!
Have you ever tried to click the link “Valid XHTML 1.0” in the footer of your blog? :-) It does not seem sooo valid…
Florian