MySQL: How To Repair & Optimize All Tables in All Databases
The following command can be used to repair and optimize all tables in a MySQL database. This can be useful on a busy server with many tables after a hard reboot or otherwise unclean shutdown. mysqlcheck -u root -p –auto-repair –optimize –all-databases