phpMyAdmin Repair and Optimize Database Tables Tutorial

Sometimes, it might be necessary to repair a MySQL database table. This can be the case if your WordPress site acts weirdly or slowly.

So, for instance, when you notice that modified settings in your WordPress dashboard are not permanently saved, it could indicate a corrupted database table.

Another indicator for a corrupted MySQL table can be if you get errors like this:

Table './wordpress/wp_redirection_404' is marked as crashed and should be repaired.

You can quickly fix this with the repair tool built-in with phpMyAdmin[1] and Adminer[2].
(Adminer is an easy to use one file DB administrating alternative to phpMyAdmin)

How to Repair MySQL Database Tables

First of all, open the phpMyadmin database administration tool.
Open the Databases tab and select the database you want to repair.

Select all tables that need repair. You can select all of them if you are unsure what table is corrupt.

How to repair MySQL database tables with phpMyAdmin

From the With Selected drop-down menu, choose Repair Table. Then all the tables will be repaired automatically. After that, you will get a presentation of the result of the repair operation.

How to Optimize MySQL Database Tables?

Optimizing database tables is needed from time to time. A MySQL database stores a lot of unused temporary data, such as queries or even data marked as deleted. So whenever you remove something from your databases, like a post or other data, it will not be deleted permanently immediately all the time. Sometimes, it still takes up some space in the system memory.

Optimizing a MySQL database table will permanently delete all this unnecessary data. So, it’s necessary to maintain your database from time to time to keep it clean and fast.

To optimize your MySQL tables, select all of them in phpMyAdmin, and choose Optimize table from the With Selected drop-down menu.

After a few seconds, you will get the result of the optimizing operation.

Author: Rene Hermenau

I'm René Hermenau, founder of WP STAGING. I've been building WordPress infrastructure software since 2013 and writing code on GitHub since 2011. My repos live at github.com/rene-hermenau. WP STAGING started as a small developer project solving the same problem I kept hitting on client work: there was no fast, safe way to clone a WordPress site for staging or migration without breaking serialized data, file paths, or media references. Today we are a team of more than 10 people. The free plugin runs on hundreds of thousands of WordPress installations, and the Pro version powers backup, migration, and staging workflows for agencies, hosting platforms, and ecommerce stores. I'm still hands-on with the codebase and technical architecture. Our releases are built as a team, but many of the core architectural decisions are ones I helped design, test, and evolve over the years: how we handle large database exports, how we keep memory usage flat on multi-GB sites, and how we make migrations atomic against partially written tables. "When you touch code, leave it 10% better than before and write a test." If you're stuck on a WP STAGING question, the docs are at wp-staging.com/docs. If you hit a bug, file it on GitHub at github.com/wp-staging. Our team reads everything that lands there.