Repairing and Optimizing all MySQL and MariaDB Databases on the Server

From time to time you will find repairing and optimizing your databases are necessary. From a shell the following may be useful for mySQL and MariaDBs:



Repair and optimized DBs

find /var/lib/mysql -name '*.MYI' -exec myisamchk -r {} \;
find /var/lib/mysql -name '*.MYI' -exec myisamchk -o {} \;

Force repair:

find /var/lib/mysql -name '*.MYI' -exec myisamchk -rf {} \;

mysqlcheck Repair and Optimize:

mysqlcheck --repair --use-frm --all-databases
mysqlcheck -o -A
  • 147 Users Found This Useful

Was this answer helpful?

Related Articles

Recursive chmod / Permission Change Across Directories for a File Type

The following command may be very useful for changing the permissions of a file type such as .php...

Permission denied: /home/username/ htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable

When checking your error log you find the error 508 or 403 forbidden error in your browser and...

VPS Time not Correct with Time Server

If you have a problem with your VPS time not staying sync in a Xen VPS you will want to enable...

cPanel Account - PHP Startup: Unable to load dynamic library

PHP Warning:  PHP Startup: Unable to load dynamic library './xsl.so' - ./xsl.so: cannot open...

Error: rpmdb open failed with cPanel

This can occur with older packages sitting on your drive. Try running the following: rm -f...