My database ‘Crashed’ what do I do?

OK, so you have error messages. Your current database is corrupted, but it will not fix and therefore you can not get into admin – what do you do? – Have you a backup? – but how do you access it?

If you are working on fixing a live site, then people could still be trying to access your site. They could do so while you are still trying to sort the site out.

1. Don’t Panic

Keep visitors out of the way?

We can not take the entire site offline easily, but there is a quick way to secure the main page, which will give us some protection. You can upload an index.html file which in most hosting environments, will take precedence for the standard index.php file called when you visit the main URL. You can put a simple message in this file like below.

<!DOCTYPE html>
 <title>Site under maintenance</title>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <div>Site Under Maintenance</div>

If you have been creating regular backups then we simply need to restart a new WordPress Installation and then you can restore your backup and be up and running again. The simple way to ‘lose’ the link with your existing database, and start with a fresh one is to remove your wp-config.php. But let’s check everything else.

You Plugins

Since we are talking about an install into the existing site, all your plugins are going to still be there waiting for you. However, till we recover the old database, all settings will be lost.

Your Theme

Since we are talking about an install into the existing site, your theme, and any other installed will be there. However, till we recover the old database, all settings will be lost.

Your uploads – images etc

Since we are talking about an install into the existing site, your uploads and images will be still there, although, without the old database, their references will be temporarily unavailable to us.

2. Can WordPress fix it for you?

You may get a message from WordPress to allow it to fix the database files for you. Let it try. If not you can also do a similar operation from the MySQL interface.  Check the database tables you want to work with or select all.

You can then choose from the pull-down menu “With selected:” and choose Repair Table. This can take some time dependent on the size of your database.

3. Start a new database and restore.

If you are concerned about creating more damage, you could select to use a new clean set of database tables and then you could restore an old version. The most simple way to do this is to edit your wp-config.sys file and give it a new database table name. (non-existent). Change the $table_prefix as shown.

 * WordPress Database Table prefix.
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers, letters, and underscores please!
$table_prefix = 'wp_';

When you try to enter the website, you will be shown the install to select the language. But beware, another visitor to the site could get the same screen first! The direct link is:

You could then activate your backup plugin and restore an older version of the database. Thus, your broken database is still available, but you have a working site and some time to contemplate.

4. Now something works

You have time to look into the broken database. To see if you are missing orders or other important information. Most importantly, you have a site working again. Don’t deny there was a problem. Better to admit there was an issue and apologise. Customers are not impressed with problems, but happy when you are able to fix things quickly.

You could set up a test/backup site and work with the broken database on there. Or, you could seek professional assistance.