mysql repair tables
Thu, 09/01/2011 - 17:21 — sandipWith a recent OS upgrade, some of the mysql database tables got corrupted. Below is how I was able to get it repaired.
-
Stop mysql server.
Once mysql server is stopped, run a repair on all of *.MYI files via myisamchk:
# myisamchk -r /var/lib/mysql/*/*.MYI
Run a mysqlcheck of all databases via:
# mysqlcheck -c --all-databases | tee /tmp/dbcheck.log
# grep error -B1 /tmp/dbcheck.log | grep -v "error\|--" | sed 's/\(.*\)/REPAIR TABLE \1;/' >/tmp/dbrepair.sql
REPAIR TABLE database1.table1;
REPAIR TABLE database1.table2;
REPAIR TABLE database2.table1;
# mysql> source /tmp/dbrepair.sql
# mysqlcheck -c -e --all-databases
- sandip's blog
- Login or register to post comments
- Read more