# Fixing database table problems in WordPress

> Repair corrupted WordPress database tables using the built-in repair tool or phpMyAdmin to fix connection errors and missing content.

Source: https://helpcenter.ruachost.com/wordpress/guides/fixing-database-table-problems-in-wordpress/

WordPress relies on its MySQL/MariaDB database to store posts, pages, users, and settings. Sometimes, database tables can become corrupted or misconfigured, leading to errors such as *“Error establishing a database connection”* or missing content. On **ruachost.com**, you can repair these tables using built‑in WordPress tools or phpMyAdmin.

## Common Causes of Database Table Problems

- Unexpected server shutdowns.
- Incomplete plugin/theme installations.
- Manual edits to the database.
- Disk or hosting environment errors.

## Method 1: Repair Database via wp-config.php

1. Log in to your hosting panel or access your WordPress files via FTP.
2. Open the **wp-config.php** file in the root directory.
3. Add the following line just before `/* That's all, stop editing! Happy publishing. */`:

   ```
   define('WP_ALLOW_REPAIR', true);
   ```
4. Save the file.
5. In your browser, visit:

   ```
   https://yourdomain.com/wp-admin/maint/repair.php
   ```
6. Choose **Repair Database** or **Repair and Optimize Database**.
7. Once complete, remove the line from **wp-config.php** for security.

✅ WordPress will attempt to fix corrupted tables automatically.

## Method 2: Repair Tables via phpMyAdmin

1. Log in to your hosting control panel (cPanel/Plesk).
2. Open **phpMyAdmin**.
3. Select your WordPress database.
4. Check the box next to the corrupted tables.
5. From the dropdown menu at the bottom, select **Repair Table**.
6. phpMyAdmin will attempt to fix the selected tables.

## Important Notes

- Always back up your database before making changes.
- If corruption persists, consider restoring from a backup.
- Some plugins may cause recurring issues, disable suspicious plugins and test.
- For large sites, use **Repair and Optimize** to improve performance.
