The Problem

While working on your MySQL server, you might come across this error in your error log:
Error:
Incorrect definition of table mysql.column_stats: expected column 'min_value' at position 3 to have type varbinary(255), found type varchar(255).
Incorrect definition of table mysql.column_stats: expected column 'max_value' at position 4 to have type varbinary(255), found type varchar(255).
This error usually shows up after an upgrade or misconfiguration and indicates that MySQL’s internal system table mysql.column_stats
has incorrect column types.
Root Cause
The columns min_value
and max_value
in the mysql.column_stats
table are expected to have the type:
varbinary(255)
But due to an unexpected change (often during manual migration or import), they are set to:
varchar(255)
These fields store binary data (like histogram stats), so having them as varchar
is not valid for MySQL’s internal use.
How to Fix It Manually via phpMyAdmin
- Login to phpMyAdmin
Go to your MySQL instance and navigate to themysql
database. - Open the
column_stats
Table
Go to the Structure tab. - Locate the Problematic Columns
min_value
(currentlyvarchar(255)
)max_value
(currentlyvarchar(255)
)
- Click “Change” on Each Column
- Change Type from
varchar(255)
tovarbinary(255)
- Keep all other settings the same (Null allowed, no default value)
- Change Type from
- Save the Changes
Final Result
Once corrected, your column types should look like this:
Field | Type |
---|---|
min_value | varbinary(255) |
max_value | varbinary(255) |
After saving the changes, you should no longer see the error in your MySQL error log.
Restart MySQL and Run Upgrade
To make sure everything is fully synchronized:
sudo systemctl restart mysql
sudo mysql_upgrade -u root -p
This ensures that MySQL validates all system tables and updates metadata if needed.
Verify It’s Fixed
Run this SQL command to confirm that column_stats
is valid:
CHECK TABLE mysql.column_stats;