There are some articles you should definitely bookmark. Like this one. A guide to repair crashed WordPress tables. A crashed posts table can put you in a mode of panic. Imagine navigating to your admin dashboard, and finding your posts and pages count as zero. But don’t worry, all your data and hard work are still there in the database. You just need to repair the crashed table and everything will be back to normal.
Identifying a Crashed Table in the Database
If you go to phpmyadmin, and select your database, a crashed table will stand out from the others all will say “in use”. If you click on the table, an error message will be shown, notifying that the table “is marked as crashed and should be repaired”.
To repair a crashed table, you need to select the table that has crashed, and then select the “Repair Table” option.
Allowing WordPress to Automatically Repair a Corrupted Database
If you do not want to meddle with the database yourself, there are several other ways to repair a crashed table. You can use the WP_ALLOW_REPAIR. In your wp-config.php, add the following:
[pre]define( ‘WP_ALLOW_REPAIR’, true );[/pre]
This will allow WordPress to automatically repair crashed tables, using a script found at {your-site}/wp-admin/maint/repair.php. Remember to disable this option in the config file, once the tables are fixed.
Using WP-CLI
If you use WP-CLI to manage your WordPress site, you can use the command, wp db repair to repair the database.
Don’t worry, any of these methods should work just fine, and your data should be back to it’s original state. Most importantly, you must remember to regularly take a backup of your database, which can save you a lot of trouble, in case something can’t be fixed or repaired.