Syntax for using mysqlcheck to optimize?

beansbaxter

Verified User
Joined
Mar 17, 2004
Messages
218
Location
WA
At the user level, DA has an option under MySQL to optimize the database.

How to perform this functionality at the command line for large databases?

mysqlcheck command?

Thanks.
 
Got it.

I saw in a very very very old post from @smtalk about using the DA admin password to accomplish this, but wasn't sure about this still being applicable today.

I was able to accomplish it from the command line and it worked good: mysqlcheck -o DB_NAME -u USER_NAME -p

Thank you.
 
I use a cron for optimizing mysql tables.
\etc\cron.daily\sqloptimize.sh
Code:
#!/bin/bash
MAILTO=root
mysqlcheck -uda_admin -p`grep "^passwd=" /usr/local/directadmin/conf/mysql.conf | cut -d= -f2` --auto-repair --optimize --all-databases

Edit: Fixed typo in crond.daily, should be cron.daily
 
Last edited:
I use a cron for optimizing mysql tables.

For others who might want the same, I would not recommend doing this without understanding all possible consequences. You might face long running locks on big tables and issues with scripts, sites, etc. Before setting the same crontask, you are advised to test online and see how fast the process goes and whether or not it causes downtimes and/or high load on your server.
 
Back
Top