How To Repair And Optimize All Mysql Databases

By | May 15, 2008

When I tried to create admin backup for DirectAdmin, I got the message that one of my MySQL databases has errors and these errors were propagated to my backup. I’d suggest this to DirectAdmin developers, as using a simple command should avoid such errors. There is a linux shell tool called mysqlcheck, that allows to check, repair and optimize mysql databases without stopping mysqld. I will show you its usage so you can run this command before creating any kind of backups.

mysqlcheck -uroot -ppass -Aor

Male sure to include MySQL root password for this operation. If you don’t know your root password, check DirectAdmin Help for information regarding it. Let’s describe used options in brief. -A tells us that all databases will be checked. -r – Repairs selected databases, -o – Optimizes selected databases. This simple operation will allow you to have only good databases in your backups. You may also add this operation to your root crontab to keep your databases optimized.