MySQL Repair and Optimize all Tables in all Databases.
MySQL tables can crash quite easily, especially when your server unexpectedly shuts down or crashed, or when you’re forced to copy data around when it’s still being accessed.
Luckily, there’s a simple command to automatically check, repair and optimize all tables in all databases when you’re running a MySQL server on Linux / Unix / BSD.
mysqlcheck -u root -p --auto-repair --check --optimize --all-databases
That’s all there is to it!
mysqlcheck is available since MySQL 3.23.38; if you haven’t slept under a rock so long you might step onto your own beard, you can probably use it on your server.