You can repair a corrupted WordPress database using the built-in WordPress repair tool or via phpMyAdmin. This process is intended for Site Administrators to resolve database errors that prevent the site from loading or cause internal server errors.
Warning: Before performing any database repairs, create a full backup of your website and database. Repair operations can lead to data loss if the database is severely corrupted or if the wrong tables are modified.
Before you begin
You will need:
Site Administrator access to the WordPress dashboard (if available)
Access to the hosting control panel (e.g., cPanel or Windows Control Panel)
Access to phpMyAdmin
Repairing via the WordPress Script
If your site is accessible but experiencing intermittent database issues, you can use the built-in WordPress repair script.
Connect to your website via FTP or use the File Manager in your hosting control panel.
Navigate to the root directory of your WordPress installation.
Locate the
wp-config.phpfile and open it for editing.Add the following line of code before the line that says
/* That's all, stop editing! Happy publishing. */:define( 'WP_ALLOW_REPAIR', true );Save the file and upload it back to your server.
Navigate to the following URL in your browser:
http://example.com/wp-content/repair.php(Replaceexample.comwith your actual domain name.)Follow the on-screen instructions to repair the database.
Important: Once the repair is complete, return to
wp-config.phpand remove the line you added in step 4 to disable the repair tool.
Repairing via phpMyAdmin
If you cannot access the WordPress dashboard or the repair script, you can repair tables directly through phpMyAdmin.
Log in to your hosting control panel.
Open the phpMyAdmin tool.
Select your WordPress database from the list on the left.
Identify the tables that are marked as "in use" or "corrupted" (often indicated by a red icon or a specific status).
Select the specific table you wish to repair.
Click the Operations tab at the top of the screen.
Locate the Repair table option and click it.
Repeat this process for any other tables showing a corrupted status.
Confirm the result
The WordPress site loads successfully without database-related errors.
The "Repair" page (if used) no longer appears when visiting the
wp-content/repair.phpURL.All site features, such as the dashboard and widgets, function as expected.
If the "Repair" option is missing in phpMyAdmin
If you do not see a "Repair" option in the phpMyAdmin Operations tab, your database engine may not support the repair command (such as InnoDB). In this case, contact Hostek support to investigate the specific table errors.
Limitations
This procedure does not fix issues caused by incorrect configuration settings or plugin conflicts; it only repairs physical database table corruption.
If a table is so severely damaged that it cannot be repaired via these methods, a restoration from a recent backup will be required.
