# How to Repair & Optimize a MySQL Database

> Canonical: https://jethost.com/kb/how-to-repair-optimize-a-mysql-database/ · Last modified: 2026-10-21T16:52:14+00:00

Over time a MySQL database can pick up small problems: a crashed table after an interrupted write, or wasted space that slows queries down. Two quick jobs keep it healthy – **repair** fixes damaged tables, and **optimize** reclaims space. This guide shows both in [phpMyAdmin](https://jethost.com/kb/phpmyadmin/).

## When you need this

Repair a database when your site shows a database error, or a table is marked as crashed. Optimize it now and then for busy sites – especially after deleting a lot of rows – to tidy up the table and keep queries fast. Both tools are available on every [JetHost web hosting plan](https://jethost.com/web-hosting/).

## Repair a database

1. Log in to cPanel and open **phpMyAdmin**.
2. Select the database in the left sidebar to see its tables.
3. Tick the tables to fix, or click **Check all**.
4. From the **With selected** drop-down, choose **Repair** **table**.

![MySQL Repair](https://jethost.com/wp-content/uploads/2026/10/MySQL-Repair.png)phpMyAdmin runs the `REPAIR TABLE` command and reports the result for each table.

## Optimize a database

The steps are identical – select the tables, then choose **Optimize table** from the **With selected** drop-down. This runs `OPTIMIZE TABLE`, which defragments the tables and updates their statistics.

![MySQL Optimize](https://jethost.com/wp-content/uploads/2026/10/MySQL-Optimize.png)## Repair from cPanel (no phpMyAdmin)

You don’t always need phpMyAdmin to repair a database. In cPanel, open **Manage My Databases** and scroll to the **Modify Databases** section. There you’ll find two tools:

1. Under **Check Database**, pick your database from the drop-down and click **Check Database** to scan it for problems.
2. If it reports an issue, select the same database under **Repair Database** and click **Repair Database**.

Each tool runs on the whole database at once, so it’s the quickest way to check and fix without opening a single table. Note that cPanel only offers **Check** and **Repair** here – for **Optimize**, use the phpMyAdmin method above.

![Check repair database cPanel](https://jethost.com/wp-content/uploads/2026/10/check-repair-database-cpanel.png)

## JetHost Experts Tip

Always take a quick [export/backup](https://jethost.com/kb/mysql-backup-restore/) before a repair. Repairs are safe in the vast majority of cases, but on a badly crashed table it’s good to have a copy to fall back on.

## Why databases get corrupted

Most table corruption comes from an interrupted write – the server losing power mid-query, a process being killed, or a disk that briefly ran out of space. A crashed table usually shows up as a database error on your site, or a plugin that suddenly can’t save. Running a repair fixes the table structure so your data is readable again. Optimizing is different: it doesn’t fix errors, it tidies up. After you delete a lot of rows, the table still reserves that space until you optimize it, so a periodic optimize on busy tables keeps queries quick and files lean.

## Need more help?

Repair not fixing the error? Open a ticket through **Client Area → Support Tickets** and our team will take a closer look at your database.
