Have an option to mysql_upgrade to only execute the SQL that upgrades the system tables: --fix-privileges-tables.
mysql_upgrade is an all-in-one program that a user must run after upgrading to the next GA release of MySQL. MySQL upgrade will: - create new system tables in mysql database - update definitions of existing mysql. system tables - check the names of the databases on the file system, to make sure that they will work properly with tablename-to-filename encoding - etc. Prior to MySQL 5.4, in addition to mysql_upgrade the server would distribute two SQL scripts: mysql_system_tables.sql and mysql_system_tables_fix.sql Prior to that, mysql_system_tables_fix.sql was called mysql_fix_privilege_tables.sql Before introduction of mysql_upgrade program, the only "fix" on upgrade that was needed was to update the privilege tables -- later to become "system" tables. Starting with 5.4 we no longer include the SQL scripts mentioned above into the server installation, in other words, do not allow the user to run them directly. Still to allow for some troubleshooting, we introduce an option to mysql_upgrade to only upgrade the system tables, in other words, not attempt to upgrade the data. The name of the option will be: -upgrade-system-tables (--fix-privilege-tables is a legacy name of an old script that we do not want to reincarnate in the option name).
Something as simple as adding a new option and modifying this piece of main(): if (run_mysqlcheck_fixnames() || run_mysqlcheck_upgrade() || run_sql_fix_privilege_tables())