Sometimes one of your Joomla database tables (jos_*) , or even your whole Joomla database can become corrupt because of the following:
– Hardware failure on your server (you should always pray that this never happens on your server, and if it does, then you should pray that you have a recent backup)
– Someone restarted the server (or shall we say, forced restart) while MySQL was trying to write to a table in your database (this is the most common scenario)
– Concurrent modifications of the same table by several programs (this scenario will probably never happen to you)
So what will happen if a Joomla table becomes corrupt?
In some cases, table corruption can be benign, in other words, you won’t see it unless you visit a specific page that wants to read and/or write data to this table. In most cases, table corruption will crash your whole website. Your website will either show a blank page and/or will return an HTTP 500 page (server error) to the user. Alternatively, your website may show PHP errors in case you have played with the error reporting of the website.
What will happen if a Joomla database becomes corrupt?
When a database becomes corrupt, then there is no way, on heaven or on earth, to have anything on your website working unless the database is fixed. In this scenario, your website will always return an HTTP 500 error to the visitor, or will show a PHP error stating that it’s having problems with the MySQL database.
In either scenario, you will see the following error if you enable PHP error reporting:
"SQL Error : 1016 Can't open file: 'databasename_jos_tablename.MYI'."
Some have reported seeing an error that starts with “Incorrect key file…”. We have personally never seen this error.
How do you fix the problem?
Fixing this problem requires that you have access to phpMyAdmin. Here’s what you should do to repair the table/database:
– Go to phpMyAdmin
– Export the database to a zip file and download it (we are backing up the database here – it’s much better to be safe than sorry). You can do this by clicking on the name of the database on the left menu, then clicking on “Export” at the top right, then clicking on SQL, and then clicking “Save as File”. If you have a lot of data, then it’s better to use a compression method such as zip or gzip.
– Once the database is backed up, go to the “Structure” tab (top left), and then select the affected tables (all the tables if the whole database is corrupt), and then click on “Repair”. This should repair everything. Note that you might lose a minimal amount of data when you do this.
– Go to your website and see if it’s working.
– If your website is still not working then it’s better to ask for professional help on your website.
Conclusion
Salvaging your Joomla website is a dangerous and critical process, and we only recommend that you do the above steps if you have at least some programming/system administration experience (you might lose everything if you make a mistake). If you prefer to have this work done by professionals, then please contact us, we’ll be happy to help you. We’ll charge you only 2 hours for this service (see our fees to know how much it would cost you), and your website will be up and running in no time.
One last word of advice, backup your website early, backup your website often!
[…] Now, in case you’re completely unlucky, your whole database may have become corrupt because of the outage. In this case, we suggest you take a look at our post: How to salvage your Joomla website. […]