Limited Time Offer!
For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

If you are running a Laravel, PHP, or any backend application and suddenly your MySQL or MariaDB server starts throwing errors like:
Incorrect definition of table mysql.column_stats: expected column ‘min_value’ to have type varbinary(255), found varchar(255)
then you are dealing with a system-level database issue, not an application bug.
This problem is very common in:
- Server migrations
- XAMPP / LAMPP environments
- MySQL โ MariaDB switching
- Version upgrades or downgrades
In this guide, we will walk step-by-step through:
- What the error actually means
- Why it happens
- How to diagnose it properly
- Safe production fixes
- Advanced debugging strategies
- Prevention best practices
Understanding the Error
From your logs:
The error repeatedly says:
- Expected:
varbinary(255) - Found:
varchar(255)
This mismatch exists in:
mysql.column_stats
This is not your application table โ it is a MariaDB system table.
What is mysql.column_stats?
This table is used internally by MariaDB for:
- Query optimization
- Statistics calculation
- Execution planning
If this table structure is wrong, MySQL/MariaDB may:
- Log errors continuously
- Fail optimization
- Cause performance issues
- In rare cases, fail to start
Root Cause (Real Scenario)
Based on your environment:
- MariaDB Version:
10.4.28 - Path:
/opt/lampp/var/mysql
This clearly indicates:
You are using LAMPP (XAMPP for Linux).
Most likely causes:
- Database files copied from another server
- MariaDB version changed but system tables not upgraded
- Mix of MySQL and MariaDB data directories
- Incomplete upgrade using mysql_upgrade
- Manual data directory replacement
Step 1: Verify Your Database Version
Run:
mysql -u root -p -e "SELECT VERSION();"
Your output:
10.4.28-MariaDB
This confirms:
- You are on MariaDB 10.4
- Your system tables must match this version
Step 2: Check Table Structure
Run:
mysql -u root -p -e "USE mysql; SHOW CREATE TABLE column_stats\G"
If you see:
min_value varchar(255)
max_value varchar(255)
Then the issue is confirmed.
Step 3: Why This Mismatch Happens
MariaDB expects:
min_value VARBINARY(255)
max_value VARBINARY(255)
But your table has:
VARCHAR(255)
Why this is a problem
VARCHARstores text with collationVARBINARYstores raw binary
MariaDB uses binary for performance and precision in statistics.
Step 4: Safe Fix (Production Recommended)
Backup First (VERY IMPORTANT)
mysqldump -u root -p mysql column_stats > /root/column_stats_backup.sql
Fix the Table
Run:
mysql -u root -p -e "
USE mysql;
ALTER TABLE column_stats
MODIFY min_value VARBINARY(255) DEFAULT NULL,
MODIFY max_value VARBINARY(255) DEFAULT NULL;
"
Restart MariaDB (LAMPP)
/opt/lampp/lampp restartmysql
Verify Fix
tail -n 50 /opt/lampp/var/mysql/*.err
If no errors โ issue resolved.
Step 5: Run Upgrade Tool (Recommended)
Even after fixing manually, always run:
/opt/lampp/bin/mysql_upgrade -u root -p --force
This will:
- Fix all system tables
- Align schema with current version
- Prevent future errors
Restart again:
/opt/lampp/lampp restart
Step 6: If Error Still Persists
Then your system tables are more deeply inconsistent.
Run:
mysqlcheck -u root -p --all-databases --repair
Advanced Fix (Last Option)
If nothing works:
- Backup all databases
- Stop MySQL
- Reinitialize system tables
- Restore data
Real-World Debugging Insight
In production systems like yours (Laravel + Keycloak + Microservices), this issue can:
- Break authentication indirectly
- Cause query performance degradation
- Trigger unexpected logs
- Affect API response times
Even if your app โworksโ, this error must be fixed.
Common Questions
Is this a Laravel issue?
No. This is a database engine issue, not application code.
Can I ignore this error?
Not recommended. It may:
- Affect performance
- Lead to future crashes
Is it safe to run ALTER on system tables?
Yes, if:
- You take backup
- You only modify expected columns
Should I drop mysql database?
Never.
This will break:
- Users
- Permissions
- Authentication
Why clearing browser cache sometimes “fixes” issues?
Because your system has:
- Multiple layers (Keycloak + API + DB)
Sometimes UI works, but DB is still inconsistent.
Prevention Best Practices
1. Never mix MySQL and MariaDB data directories
2. Always run upgrade after version change
mysql_upgrade
3. Avoid copying raw /var/mysql directories
Instead use:
mysqldump โ restore
4. Keep consistent environments
- Same MariaDB version in dev and prod
- Avoid XAMPP โ production migration without cleanup
5. Monitor logs regularly
tail -f /opt/lampp/var/mysql/*.err
Final Summary
This issue happens because:
- Your MariaDB expects
VARBINARY - Your system table has
VARCHAR
Fix is:
- Backup
- ALTER table
- Run mysql_upgrade
- Restart server
Final Production Command Set
mysqldump -u root -p mysql column_stats > /root/backup.sql
mysql -u root -p -e "
USE mysql;
ALTER TABLE column_stats
MODIFY min_value VARBINARY(255) DEFAULT NULL,
MODIFY max_value VARBINARY(255) DEFAULT NULL;
"
/opt/lampp/bin/mysql_upgrade -u root -p --force
/opt/lampp/lampp restart
Closing Note
This is a classic server-level issue that many developers misinterpret as an application bug. Fixing it correctly improves:
- Stability
- Performance
- Reliability
