How to fix ERROR 1558 (HY000): Column count of mysql table wrong in MySQL

MySQLINTERMEDIATEHIGHUpdated Dec 25, 2025ยท 233 views

This error occurs when MySQL system tables have a different number of columns than expected by the current MySQL version, typically after an incomplete upgrade. The fix is to run the mysql_upgrade utility to synchronize your system tables with your current MySQL version.

Quick fix

Fixes 1558

# On systemd systems (Linux)
sudo systemctl stop mysql

# Or on traditional systems
sudo service mysql stop

# On macOS with Homebrew
brew services stop mysql@8.0

# Or manually kill the process
sudo mysqladmin shutdown
  1. Stop the MySQL server if it's still running
  2. Run mysql_upgrade to fix system tables
  3. Restart the MySQL server
  4. Verify the fix by connecting to MySQL
mysql โ€” error
# On systemd systems (Linux)
sudo systemctl stop mysql
# Or on traditional systems
sudo service mysql stop
# On macOS with Homebrew
brew services stop mysql@8.0
# Or manually kill the process
sudo mysqladmin shutdown
ERROR 1558 (HY000): Column count of mysql table wrong

What this error means

MySQL maintains internal system tables (like mysql.proc, mysql.user, mysql.func) that store metadata about stored procedures, users, and functions. These tables have a fixed structure that changes between MySQL versions. When you upgrade MySQL without properly upgrading these system tables, the running MySQL server expects a certain number of columns in these tables, but finds a different number instead. The error message typically looks like: "ERROR 1558 (HY000): Column count of mysql.<table_name> is wrong. Expected X, found Y. Created with MySQL VERSION_A, now running VERSION_B." This is a critical error because it prevents the MySQL server from accessing its own system tables, which can block basic operations like user authentication and stored procedure execution.

Typical symptoms

  • MySQL server fails to start or crashes during initialization
  • Authentication fails with error 1558 even for valid credentials
  • Stored procedures and functions become inaccessible
  • MySQL won't respond to any commands and appears hung
  • Error appears in error logs immediately after MySQL upgrade

Common causes

  1. MySQL was upgraded to a newer version without running the mysql_upgrade utility
  2. The mysql_upgrade process was interrupted before completing
  3. Manual downgrade to an older MySQL version without running downgrade procedures
  4. System tables were corrupted or manually altered
  5. Incomplete database migration between different MySQL variants (MySQL to MariaDB or vice versa)

How to fix "ERROR 1558 (HY000): Column count of mysql table wrong"

1Stop the MySQL server if it's still running

First, gracefully shut down the MySQL service to prevent any data corruption:

bash
# On systemd systems (Linux)
sudo systemctl stop mysql

# Or on traditional systems
sudo service mysql stop

# On macOS with Homebrew
brew services stop mysql@8.0

# Or manually kill the process
sudo mysqladmin shutdown

Wait a few seconds to ensure the process has fully stopped before proceeding.

2Run mysql_upgrade to fix system tables

The mysql_upgrade utility updates MySQL system tables to match your current MySQL version. This is the primary fix for ERROR 1558:

bash
# Standard invocation (prompts for password)
mysql_upgrade -u root -p

# Non-interactive if you have .my.cnf configured
mysql_upgrade -u root -p --password=your_password

# Force the upgrade even if tables seem compatible
mysql_upgrade -u root -p --force

The utility will:
- Check all tables in all databases for compatibility
- Upgrade system tables to the current version
- Rebuild the privilege tables with new columns
- Clear deprecated columns and settings

3Restart the MySQL server

After mysql_upgrade completes successfully, restart the MySQL service:

bash
# On systemd systems
sudo systemctl start mysql

# Or on traditional systems
sudo service mysql start

# On macOS
brew services start mysql@8.0

The server should start without errors. If you still see ERROR 1558, there may be additional corruption.

4Verify the fix by connecting to MySQL

Test that MySQL is working properly and the error is resolved:

bash
# Connect to MySQL
mysql -u root -p

# At the MySQL prompt, run:
SELECT VERSION();
SELECT COUNT(*) FROM mysql.user;
SHOW TABLES FROM mysql;

If these commands execute successfully without ERROR 1558, the issue is fixed. Your databases and data remain intact.

5For MariaDB: Use mariadb-upgrade instead

If you're using MariaDB instead of MySQL, use the MariaDB-specific upgrade command:

bash
# Stop MariaDB
sudo systemctl stop mariadb

# Run MariaDB upgrade utility
mariadb-upgrade -u root -p

# Restart MariaDB
sudo systemctl start mariadb

In newer versions of MariaDB/MySQL, the upgrade is performed automatically on startup if system tables are out of date.

Advanced notes

For MySQL 8.0.16 and later: The mysql_upgrade utility has been deprecated. Instead, the MySQL server automatically performs all necessary upgrade steps on startup when it detects that system tables are out of date. Simply starting the new MySQL version with your old data directory will trigger an automatic upgrade. No restart is needed after the automatic upgrade completes.

For Docker users: If you encounter this error in a Docker container, ensure you're upgrading the base image properly:

bash
# Stop and remove the old container
docker stop mysql_container
docker rm mysql_container

# Update to a new MySQL image
docker pull mysql:8.0.40  # or your target version

# Run the new container with your old data volume
docker run -v mysql_data:/var/lib/mysql mysql:8.0.40

Backup before upgrade: While mysql_upgrade is generally safe, always have a backup before performing major version upgrades:

bash
mysqldump -u root -p --all-databases > backup.sql

SELinux and AppArmor: If you're on a system with SELinux or AppArmor enabled, ensure the MySQL process has permission to read and write to the data directory after upgrade. If mysql_upgrade runs as root but the MySQL daemon runs as 'mysql' user, permission issues may occur.

Frequently asked questions

What does "1558" mean?
func) that store metadata about stored procedures, users, and functions. These tables have a fixed structure that changes between MySQL versions. When you upgrade MySQL without properly upgrading these system tables, the running MySQL server expects a certain number of columns in these tables, but finds a different number instead.
How do I fix "1558"?
This error occurs when MySQL system tables have a different number of columns than expected by the current MySQL version, typically after an incomplete upgrade. The fix is to run the mysql_upgrade utility to synchronize your system tables with your current MySQL version.
What causes "1558"?
MySQL was upgraded to a newer version without running the mysql_upgrade utility The mysql_upgrade process was interrupted before completing Manual downgrade to an older MySQL version without running downgrade procedures
Is the "1558" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading