Repair WordPress Database Issues Without Losing Data

repair wordpress database featured image

If your WordPress database is causing errors, you need a clear way to fix the problem without putting your site’s data at risk.

The safest approach is to create a backup first, confirm that WordPress can connect to the database, and then choose a repair method that matches the access you have.

This guide to repair WordPress database problems walks you through each option, from the simplest fixes to more advanced methods, so you can restore your site with confidence.

TL;DR: Use a backup plugin, such as BlogVault, or your host to backup the site and database first. Then check the database details, use the WordPress repair page, phpMyAdmin, WP-CLI, host tools, or a database plugin only when that method fits the problem.

If tables are missing or recent data has disappeared, do not keep running repair. Restore from a clean backup or ask your host to recover the database.

What a database repair can fix

WordPress uses PHP for site code and MySQL or MariaDB for the database. The database stores posts, pages, users, comments, settings, menus, plugin data, theme settings, orders, and form entries. A database issue can look like:

  • Connection failure: WordPress shows Error establishing a database connection.
  • Missing content: posts, pages, users, orders, or settings disappear.
  • Broken admin: wp-admin is slow, frozen, or fails during saves.
  • Failed tasks: publishing, imports, exports, or migrations stop midway.
  • Table errors: WordPress or phpMyAdmin says a table is crashed, corrupt, or missing.

These signs point to different fixes:

ProblemBest first move
WordPress cannot connectCheck the database name, user, password, host, and server status
A table is crashed or corruptedBack up, then repair the table
The dashboard is slowCheck plugins, database bloat, traffic, and hosting limits
Data or whole tables are missingRestore a backup or ask the host for recovery

Repair can fix damaged tables when the database engine supports repair. It cannot recreate deleted rows, recover missing tables, fix the wrong password, or bring a down database server back online.

Backup before repair

BlogVault backups new UI

Take a fresh backup before any repair step, even if the site is already broken. A damaged database may still contain new orders, users, comments, form entries, or posts that are not in your last good backup.

Use a backup plugin if WordPress still loads. BlogVault fits this job because it gives you a recovery point before you touch the database. If wp-admin is down, use your host backup tool or export the database from phpMyAdmin.

Backup checklist before WordPress database repair

For WooCommerce, membership, LMS, booking, and subscription sites, check the time of the backup before restoring. An older database can erase orders, payments, signups, and form entries created after that backup.

🛟 Note: If phpMyAdmin cannot export a large database, ask your host for a server-side database dump, which is a backup created directly on the server. Do not skip the backup because one export screen failed.

Check the cause first

Many database emergencies are not corruption. Check the basics before you repair anything.

  • Confirm the connection details in wp-config.php: Match DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST with the values in your hosting account. A changed password, migrated host, wrong database name, or wrong host value can cause Error establishing a database connection.
  • Confirm the table prefix: WordPress uses $table_prefix to know which table names belong to the site. If the database tables start with site_ but the config file says wp_, WordPress may act as if the tables are missing.
  • Ask whether the database server is healthy: Your host may have a MySQL or MariaDB outage, disk issue, connection limit, or traffic spike. Repair does not fix a database server that is down or overloaded.
  • Use logs when the site still runs: WordPress debug logging can separate plugin errors, PHP errors, and database errors. Keep public error display off so visitors do not see private paths or warnings.

⚠️ Note: Do not rename tables or change prefixes by guesswork. A wrong prefix is fixable, but random changes can make recovery harder.

Choose the repair method

Pick one path based on what you can still access.

What still worksUse this method
You can edit files, but wp-admin is brokenWordPress repair page
You can open hosting database toolsphpMyAdmin
You have SSH accessWP-CLI
Your host offers repair toolsHosting control panel
wp-admin still worksDatabase plugin
Tables or data are missingBackup restore or host recovery

Do not run every method in a loop. If a repair says the tables are fine, or says the storage engine does not support repair, repeating the same action usually will not help.

Use the WordPress repair page

Use this when wp-admin is broken but you can edit wp-config.php.

locate-the-wp-config-file-in-public-html
  • Add the repair setting in wp-config.php: Add define( ‘WP_ALLOW_REPAIR’, true ); above the line that says to stop editing.
  • Open the repair page directly: Visit https://example.com/wp-admin/maint/repair.php and replace example.com with your domain.
WordPress repair page with repair and optimize options
  • Choose Repair Database first: Use the shorter repair option during an outage. Use Repair and Optimize Database later if the site is stable and you want WordPress to reduce wasted table space.
  • Save every result message: If WordPress names a table that cannot be repaired, copy the exact message before you close the page.
  • Remove the repair setting immediately: Delete WP_ALLOW_REPAIR from wp-config.php as soon as you finish.

🔒 Note: The repair page does not require a normal WordPress login once enabled. Leave it on only while you are using it.

Repair tables in phpMyAdmin

Use this when you can access your hosting panel and database tools.

  • Match the database name before selecting anything: Open wp-config.php and note DB_NAME. In phpMyAdmin, select that exact database from the left sidebar.
  • Select the WordPress tables carefully: Use Check all for the whole WordPress database, or start with the table named in the error message on a large site.
  • Run the repair action: Choose Repair table from the bulk action menu and read the result.
  • Handle storage engine warnings correctly: MySQL and MariaDB can repair tables that use engines such as MyISAM, ARCHIVE, CSV, and MariaDB Aria. Many modern WordPress sites use InnoDB. If phpMyAdmin says the storage engine does not support repair, the database is not automatically lost. InnoDB uses a different recovery process and may need a database restart, host help, or backup recovery.
  • Check whether tables are actually missing: If WordPress says wp_users does not exist but phpMyAdmin shows tables with a different prefix, the config prefix may be wrong. If the WordPress default tables are gone, repair cannot recreate them.

Run WP-CLI repair

Use this when you have SSH access, which means command-line access to the server, and WP-CLI is available.

  • Move into the WordPress root folder: Open the folder that contains wp-config.php.
  • Export a database copy first if you can: If SSH still works, use wp db export before repair so you have a current SQL file outside WordPress.
  • Run the repair command: Use wp db repair. WP-CLI reads the database login details from wp-config.php and runs the repair.
  • Read the output before moving on: A successful run returns Success: Database repaired. If it cannot connect, check the credentials and database server. If it names a table or storage engine error, save the output for your host.
  • Optimize only after the site is stable: Use wp db optimize later if you need to reduce overhead, which is wasted table space. Optimization is not a fix for missing data or connection errors.

Use your host panel

Use this if your host provides database repair tools and you do not want to work inside phpMyAdmin.

  • Open the database section in hosting: In cPanel, this is often under MySQL Databases. In Plesk, the database page may include Check and Repair.
  • Choose the correct database: Match it to DB_NAME in wp-config.php before running any action.
  • Run check or repair once: Save the result messages, especially if the tool names a damaged table.
  • Ask for server checks if damage returns: Recurring corruption can point to disk problems, database crashes, resource limits, bad code, malware, or unstable hosting.

Use a database plugin

Use a plugin only if wp-admin still works. A plugin cannot help when WordPress cannot connect to the database.

  • Install only the tool you need: A database plugin can repair tables, optimize tables, clean expired transients, remove spam comments, and delete old revisions. It can also add load to a weak site, so avoid this during a full outage.
  • Review cleanup options one by one: Revisions, drafts, WooCommerce records, user metadata, and plugin data are not the same. Do not delete data just because a plugin calls it cleanup.
  • Back up before cleanup too: Cleanup deletes data by design. Repair tries to fix damaged tables. Those are different jobs.

🧹 Note: If you are not sure what a cleanup option removes, skip it until you have a fresh backup and a reason to delete that data.

When repair fails

Stop and classify the failure instead of repeating the same repair.

  • Connection error remains: Check database credentials, user permissions, host value, server status, and connection limits. Table repair does not fix a login or server problem.
  • Crashed table will not repair: Save the table name and error text. Your host may need to run a server-level repair or restore that table from backup.
  • InnoDB repair is not supported: Ask the host to check database logs and crash recovery. Repeating phpMyAdmin repair will not force InnoDB to work like MyISAM.
  • Tables are missing: Check DB_NAME and $table_prefix. If both are correct and the tables are gone, restore a backup.
  • Migration or import broke the database: Avoid manual fixes to indexes, primary keys, auto-increment values, or serialized data unless you know what changed. These control how rows connect to each other, and a small mistake can spread.
  • The same issue keeps returning: Scan for malware and review recent plugin, theme, and server changes. MalCare is useful when suspicious changes or recurring corruption suggest a hacked site, because cleanup matters more than another repair run.

Verify the site after repair

After repair, check the areas where data loss would hurt most.

  • homepage and important pages
  • wp-admin login
  • Posts, Pages, Users, Settings, and menus
  • WooCommerce orders, products, checkout, and payment callbacks
  • forms, memberships, subscriptions, and downloads
  • recent comments, users, orders, and form entries
  • error logs and debug logs
  • backup status
  • cache, CDN, and object cache behavior

Then remove temporary settings. Delete WP_ALLOW_REPAIR if you used the repair page. Turn off public debugging. Clear caches after the database responds correctly.

Note: If you restored a backup, compare the backup time with the newest real activity on the site. Payment records, emails, and form notifications can show what needs manual recovery.

Prevent repeat repairs

Keep reliable backups, update WordPress core, themes, and plugins, and remove plugins you no longer use. Use a backup plugin that stores copies away from the live site, because a database failure can affect anything stored on the same server.

Watch for patterns. If the same table fails again, ask your host to check MySQL or MariaDB logs, disk health, memory limits, and recent restarts. If the database is huge, clean it carefully after a backup. Large tables such as post metadata can slow exports and migrations even when they are not corrupt.

Optimization can help after repair or cleanup. It reorganizes table storage and can reduce wasted space. It does not recover missing rows, rebuild lost tables, or fix bad credentials.

FAQs

How do I repair a WordPress database without wp-admin?

Use the WordPress repair page if you can edit wp-config.php, or use phpMyAdmin, WP-CLI, or your host database repair tool. Back up the database first.

Should I choose Repair Database or Repair and Optimize Database?

Choose Repair Database first during an outage. Use Repair and Optimize Database after the site is stable if you want to reduce table overhead.

Why does phpMyAdmin say repair is not supported?

The table may use InnoDB, which handles crash recovery differently from older table engines such as MyISAM. Ask your host to check the database server or restore from backup if the table still fails.

Can repair recover missing posts or orders?

Usually no. Repair can fix damaged tables, but it does not recreate missing rows or tables. Restore a backup and compare recent orders, forms, comments, and user registrations before rolling back.

Is a plugin enough to repair a corrupted database?

Only if wp-admin still works and the problem is mild enough for WordPress to load. For a fully offline site, use the built-in repair page, phpMyAdmin, WP-CLI, host tools, or restore a backup.

Conclusion

The safest way to repair WordPress database issues is to slow down for the first few minutes. Back up the current site, check the database details, confirm the server is reachable, and then choose one repair method that matches your access. That order protects recent data while still getting you to the fix quickly.

Repair is only one part of recovery. If tables are missing, restore from a clean backup. If the same table breaks again, look for the cause in hosting, malware, bad code, or resource limits. A good backup plugin and careful post-repair checks make the next database problem much less stressful.

Tags:

You may also like


How do you update and backup your website?

Creating Backup and Updating website can be time consuming and error-prone. BlogVault will save you hours everyday while providing you complete peace of mind.

Updating Everything Manually?

But it’s too time consuming, complicated and stops you from achieving your full potential. You don’t want to put your business at risk with inefficient management.

Backup Your WordPress Site

Install the plugin on your website, let it sync and you’re done. Get automated, scheduled backups for your critical site data, and make sure your website never experiences downtime again.