Mariadb mysql_upgrade执行失败求助:从10.1.36升级至10.2.30后报错
Hey there, let's break down why your mysql_upgrade is failing at step 4. Based on common issues with this specific upgrade path, here are the most probable causes and actionable fixes:
Corrupted or inconsistent system tables
MariaDB 10.2 introduced changes to core system tables (like adjustments to themysql.usertable structure). If your pre-upgrade system tables had any corruption or inconsistencies, the upgrade process can get stuck at step 4.
Fix: First, repair all databases and tables with themysqlchecktool before re-running the upgrade. Execute this as the root user:mysqlcheck --all-databases --repair --extended -u root -pEnter your root password when prompted, then try running
mysql_upgrade -u root -pagain.Insufficient privileges for the upgrade user
If you're not runningmysql_upgradewith a user that has full access to system databases, the process can fail when trying to modify critical tables.
Fix: Always run the upgrade command with the root user (or a user withALL PRIVILEGESon themysqldatabase andSUPERprivilege). Use this explicit command:mysql_upgrade -u root -pStale processes or lock files blocking the upgrade
Interrupted processes from the initial upgrade can leave behind locks or stray mysqld threads that interfere withmysql_upgrade.
Fix:- Stop the MariaDB service entirely:
(Usesystemctl stop mariadbservice mariadb stopif you're on an older Linux distro without systemd) - Check for remaining mysqld processes:
Kill any leftover processes withps aux | grep mysqldkill <process_id>if needed. - Restart the MariaDB service:
systemctl start mariadb - Re-run the upgrade command.
- Stop the MariaDB service entirely:
Conflicting settings in your my.cnf configuration
MariaDB 10.2 has new default configuration values that might clash with your oldmy.cnffile (e.g., changes tosql_modeor system table parameters).
Fix: Temporarily rename your existing config file to avoid conflicts:mv /etc/my.cnf /etc/my.cnf.bakStart MariaDB with default settings, run
mysql_upgrade -u root -p, then restore your config file and adjust any settings that don't align with 10.2's requirements.
If your screenshot shows a specific error message (like a mention of a particular system table), you can narrow down the fix by repairing that table specifically with mysqlcheck --repair mysql <table_name>.
内容的提问来源于stack exchange,提问作者Jakub Barták

