This tutorial is for people using a web host that uses the cPanel interface (version 11.34.1).
Instructions may be the same for other versions or interfaces, but not guarantee is made.
When we set up a website, we expect it to keep working. Maybe we have to apply periodic updates and patches, but, in general, we expect it to keep working.
Unfortunately, after a while, you may find your website, powered by Joomla!, WordPress, Drupal or some other CMS, stops working correctly.
Common symptoms include:
I have experienced all these on Joomla! and WordPress powered sites I run.
- Some or all of the comments disappear
- Some or all of the content disappears
- You get database connection errors
- Your layout / template starts looking a bit funny
- Pages you know exist start generating
HTTP 404 Not Found
errors - URLs start looking funny
A common cause of these problems is a corrupted MySQL database.
There may be other reasons for these (and other) problems, but a corrupt database is one of them.
Checking if the Database is Corrupted
1) Log into your web hosting control panel. This is not your website’s admin panel. For this tutorial, I am assuming it is cPanel. It might look something like this (this is how mine looks):
2) Click on MySQL® Databases:
3) Locate the section titled Modify Databases. On the line titled Check DB: select the database to check from the dropdown box. Click the button Check DB (located on the right side):
Note: if you only have one website hosted, then choosing the appropriate database is easy. If you have multiple sites, then you will have to figure out which database belongs to which site.
It does not hurt to check them all.
4) Examine the report generated. There should be no errors. If there are errors, then your database is corrupted and needs to be repaired.
Note: if your website is a busy website, you may get errors (usually something along the lines of table not closed
) because the database is in the middle of being used. If you run the test again and the errors go away, then it probably is because the database was in use and not because the database is corrupted.
This is an example of a corrupted WordPress database:
This is an example of a corrupted Joomla! database:
Repairing the Database
This is not the recommended way, but it should work in most cases.
Most often, the problem is not with the actual database itself, but with the index files used to access the database.
You can read more about how it works here (warning, external site).
The preferred method is to restore the corrupted database with an up to date backup of your database. This supposes you have an up to date backup.
1) Locate the section titled Modify Databases. On the line titled Repair DB: select the database to repair from the dropdown box. Click the button Repair DB (located on the right side):
This will begin a repair operation on the database.
After the operation has completed, check the database again. If there is still a problem, then run Repair DB again. I have, sometimes had to run it twice.
Afterwards, it does not hurt to check your site and content to ensure everything is ok. This is a lot of work if you have many articles to check.
Restoring the Database from a Backup
1) Click on Backups (located on your cPanel home page):
2) Locate the section called Restore a MySQL Database and click on Browse… and select the backup database from your computer. Click on Upload to upload the database.
During this process, not much may seem to be happening.
The backup database has to be uploaded from your system to your service provider.
Once it is uploaded to the service provider, the existing database is rebuilt from the uploaded one.
The whole process looks something like this:
What you see happening is a whole bunch of MySQL transactions that delete the contents of the old database and replace it with the contents of the backup database.
If you are interested in database development, this is a good instructional example of some MySQL commands in action.
Restoring from backup, means you will lose any changes that occurred from the time of the backup until the time of the database corruption. Normally, this will be things like: comments, registrations, traffic information (if thissort of thing is stored in the database). While these things vary in importance, I believe the most important thing is the content.