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

Share this page:

Was this article useful? Have any suggestions or improvements to the information?

Also Read

Nginx redirecting folder to another host or server

From time to time you may want to proxy out a path to another server or location. To perform a...

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...

Manually Clear from Console / Command Line cPanel Exim Mail Queue

To clear the cPanel exim mail queue quickly from a command line / shell use the following...

Remount /tmp with exec permission

There are times where you may need to have exec permission available for the /tmp folder. This...

FSCK Options and Maintenance

Provided below are some useful commands pertaining to FSCK. Update commands to your environment /...