phpMyAdmin 'Cannot display table structure' fix
phpMyAdmin shows 'Cannot display table structure' when the information_schema is corrupted or a table has no primary key. Here's how to fix both cases.
Quick Answer (for advanced users)
Run REPAIR TABLE your_table_name; or OPTIMIZE TABLE your_table_name; in MySQL CLI. If that doesn't work, restart MySQL server, then run mysql_upgrade -u root -p from terminal.
What's happening here
You're in phpMyAdmin, you click on a table name, and instead of seeing the column names, types, and keys, you get a red box that says "Cannot display table structure". This usually happens after a MySQL crash, a failed import, or when a table got corrupted. I've seen this most often after a power outage at a client's office where the MySQL server was running on an old Windows 2008 machine.
The real root cause is one of two things:
- The
information_schemadatabase (MySQL's internal metadata store) got corrupted or out of sync. - The table you're looking at has no primary key, and phpMyAdmin's version (especially 4.x and early 5.x) can't figure out the structure.
Let me walk you through fixing both cases. Start with the easy stuff, then we'll get into the heavier fixes.
Fix Steps (start here)
-
Log into MySQL directly using the command line. Don't use phpMyAdmin for this — it's the thing that's broken.
Open a terminal (Linux/Mac) or command prompt (Windows) and type:
mysql -u root -pEnter your MySQL root password when prompted. You should see a
mysql>prompt. -
Select your database. Replace
your_database_namewith the actual name:USE your_database_name;You'll see "Database changed" if it worked.
-
Check the table causing the problem. Run this command to see if the table exists and has any obvious issues:
CHECK TABLE your_table_name;Replace
your_table_namewith the table that triggered the error in phpMyAdmin. The output will showMsg_text— if it saysOKorTable is already up to date, the table itself is fine. If it saysCorruptorError, that's your problem. -
Repair the table if it's corrupt. Run:
REPAIR TABLE your_table_name;After this runs, you'll see a status message like
status | OK. If it sayswarning, that's usually fine — it means some indexes were rebuilt. -
If the table isn't corrupt, check if it has a primary key. Run:
SHOW CREATE TABLE your_table_name;Look at the output. If you don't see
PRIMARY KEYanywhere, that's your issue. phpMyAdmin (especially versions 4.5.x to 5.0.x) gets confused when a table has no primary key. It can't determine the table structure internally. -
Add a primary key to the table. If the table has an
idcolumn or any unique column, use it. For example:ALTER TABLE your_table_name ADD PRIMARY KEY (id);Replace
idwith your actual column name. If the table doesn't have a good candidate column, add one:ALTER TABLE your_table_name ADD COLUMN id INT AUTO_INCREMENT PRIMARY KEY FIRST;This adds an auto-incrementing integer ID as the first column and sets it as the primary key. After this, go back to phpMyAdmin and refresh — the structure should show up.
-
If step 4 didn't fix it, repair the information_schema. Exit the MySQL prompt (
EXIT;) and restart the MySQL service. On Linux:sudo systemctl restart mysqlOr on older systems:
sudo service mysql restartOn Windows, open Services (services.msc), find MySQL, right-click and select Restart.
After the restart, run the MySQL upgrade tool:
mysql_upgrade -u root -pThis checks all tables and the
information_schemaagainst the current MySQL version and fixes any mismatches. It can take a minute or two depending on how many databases you have. -
Clear phpMyAdmin's cache. Close your browser completely, reopen it, and log back into phpMyAdmin. Click on the table again. The structure should now be visible.
Alternative fixes if the main one doesn't work
Fix for phpMyAdmin 5.2 and newer
If you're using phpMyAdmin 5.2 or later, there's a known bug with SHOW TABLE STATUS caching. Open config.inc.php in your phpMyAdmin directory (usually /usr/share/phpmyadmin/ on Linux or C:\xampp\phpMyAdmin\ on Windows with XAMPP). Add this line:
$cfg['ShowDatabasesNavigationAsTree'] = false;
Save the file, then clear your browser cache and reload phpMyAdmin. This disables the tree view for databases, which sometimes breaks table structure display on large databases.
Fix for MySQL 8.0 compatibility
MySQL 8.0 changed how information_schema works. If you upgraded MySQL from 5.7 to 8.0 without running mysql_upgrade, that's your problem. You need to run:
mysql_upgrade -u root -p --force
The --force flag tells it to re-check everything even if the system thinks it's up to date. After this, restart MySQL again.
Export and reimport the table (last resort)
If nothing above works — and I mean you've tried all of it — then the table's internal structure is really messed up. Here's the nuclear option:
- Back up the table data:
mysqldump -u root -p your_database your_table_name > backup.sql - Drop the table:
DROP TABLE your_table_name; - Recreate it using the backup:
mysql -u root -p your_database < backup.sql
This gives you a fresh table with a clean structure. Make sure the backup.sql file includes the CREATE TABLE statement — it should by default.
Prevention tip
The number one reason this happens is running an old version of phpMyAdmin that doesn't match your MySQL version. Before you do anything else, check your phpMyAdmin version (look at the bottom of the login page or the main dashboard). If it's older than 5.2.1, upgrade to the latest. I recommend phpMyAdmin 5.2.1 or higher for MySQL 8.0, and 4.9.11 for MySQL 5.6 or 5.7. Mixing versions causes these structure errors all the time.
Also, always add a primary key to every table. It's not just about phpMyAdmin — MySQL uses the primary key for performance and replication. If you have a table without one, you're asking for trouble. I know it's annoying when you're just storing log data, but put an auto-increment ID on it. Future you will thank present you.
Was this solution helpful?