Scott Klarr Jr
Optimize and repair all mysql databases at once
Posted On Mar 06, 2008 at 1:27 am
There is a really handy MySql utility called mysqlcheck that allows you to do a number of actions to all databases on your mysql server at once. I am writing this specifically for Linux, but I'm sure windows and Unix versions are very similar if not exactly the same. Run this command as root (super user)
mysqlcheck -Aor
mysqlcheck -Ar
mysqlcheck -Ao
Argument Definitions
-A - Check all Mysql databases
-r - Repair all Mysql databases
-o - Optimize all Mysql databases
To see all of the available options, run mysqlcheck --help



Vladimir May 15, 2008
You should also add mysql root password to this command. In the example shown MySQL password is not set, that seems to be a risky configuration
Aaron Moon Jul 02, 2008
WOW this is a nice tool, I have actually set this to run as a cron job, and post the output to an admin mail I have this run about once per week late sunday to insure low load times.....
cjk Sep 04, 2008
No you should not add the mysql root password, because it would potentially be visible when you do `ps aufwwx`. At least when you do it interactively, don't use -pXYZ.
Stelian Oct 23, 2008
thank you for this great info
Adam Jan 28, 2010
Thank You. Great info.
Asad Hasan Jun 21, 2010
I was trying to dump all of my databases at once but some of em were crashed and this really saved me the effort of individually going in and repairing them individually. THANK YOU SO MUCH FOR THE INFORMATION!!!
Giovanni ~ Quacos Jun 29, 2010
This is really better than repairing each database through PHPMyAdmin ;)