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

Killing cPanel Backups via Command Line / Shell

From time to time you may find the cPanel backup system taking longer and affecting production...

How to convert InnoDB to MyISAM

Although at times faster, you will find InnoDB a very large headache when it comes to table...

Remount /tmp with exec permission

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

Error: rpmdb open failed with cPanel

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

Whitelisting Multiple IPs with Mod_Security

The following can be added to the main modsecurity.conf or a whitelist file such as one...