Live in a world of your own, but always welcome visitors.

View on GitHub
18 November 2015

Bulk clean corrupted MySQL tables under Linux

by deaves

Recommend shutting down the MySQL running service: /etc/init.d/mysql stop

To scan all DB files for errors: myisamchk -s /var/lib/mysql/*/*.MYI

To fix a courted Database: myisamchk -r -update-state /var/lib/mysql/DIR/file.MYI

To automate the scanning and fixing of all DB files: myisamchk -s /var/lib/mysql/*/*.MYI 2>&1 | grep ^MyISAM | awk '{print $2}' | sed "s/’//g" | sort | uniq | while read DBFILE; do myisamchk -r -update-state $DBFILE; done