Lightroom 3 Book for Digital Photographers by Scott Kelby »

How to Repair and Optimize MySQL database using cPanel and phpMyAdmin

Database Repair using cPanel

In some webhosts, they will have an utility via their cPanel to repair a MySQL database if your database get corrupted.  Depending on the nature of the corruption, there is no guarentee of fix, but it is worth to try. And if you happen to run "repair" when there is nothing wrong with your tables, there is no harm.  Nevertheless, it is always a good idea to backup the database first. 

Using Hostmonster or BlueHost as an example, the process of performing the database repair would be ...

  1. Log into the webhost's cpanel.
  2. Click on "MySQL databases".
  3. Under the "Modify Database" section, select the database. And click "Check DB".
  4. Under the "Modify Database" section, select the database and click "Repair DB". 

This works for the MyISAM MySQL database type. But for InnoDB database type (as is used by with some PHP applications such as Gallery2), you may get the error "The storage engine for the table doesn't support repair".  In this case, you can still optimize the database by doing using phpMyAdmin tool (also found in cPanel for certain webhosts).  See following section.

Optimize Database using the phpMyAdmin  

If you find that your database is running slow,
it is a good idea to optimize your database tables to help maintain optimal
performance.  One way to do this is via the phpMyAdmin web database tool.

  1. Click on phpMyAdmin to start it.
  2. Select the database you want to optimize on the upper left
  3. Checkmark the tables you want to optimize (usually checkmark all)
  4. Using the selection box at the bottom, select "Optimize Table" or "Repair Table".

For more info, see Newista's video tutorial for using phpMyAdmin to optimize table or read SiteGround's knowledge base article "How to optimize a MySQL database".