MySQL databases require regular maintenance, but usually the databases just need to be re-optimized and checked for errors. In such cases, having to go through each database on your server can be time consuming. Following these steps, you can setup a cron job that will automatically check and repair your databases.
1. Login to the server via SSH
2. Edit the crontab file found in /etc/crontab
# crontab -e
3. Enter the following line in the crontab file:
0 1 * * * mysqlcheck -Aao –auto-repair -u root -p[password] > /dev/null
This will check all databases on the server. If you do not have root access and only want to check your own website, you can edit your cron in your control panel or replace the “root” user with your MySQL username. Save the file, and cron will now start mysqlcheck at 1 am everyday to optimize and check all databases.
Source: My Digital Life
Photo: Flickr