MySQL error [Warning] InnoDB: Table mysql/innodb_index_stats has length
# 问题:
查看从库MySQL日志发现有如下报错:
2025-01-08T08:45:55.637138+08:00 0 [Warning] InnoDB: Table mysql/innodb_index_stats has length mismatch in the column name table_name. Please run mysql_upgrade
# 原因:
Bugs Fixed
Important Change; Partitioning: After creating partitioned InnoDB tables with very long names, the table_name columns in the corresponding entries in the mysql.innodb_index_stats and mysql.innodb_table_stats system tables were truncated. To fix this issue, the length of the table_name column in each of these tables has been increased from 64 to 199 characters. In both cases, this is now the same as the lengths of these columns in MySQL 8.0.
When upgrading to this release, use mysql_upgrade to effect these changes in your MySQL installation. In the event that you fail to do this, MySQL generates the warning Table mysql/innodb_table_stats has length mismatch in the column name table_name. Please run mysql_upgrade in the error log.
# 解决方案:
版本:
mysql> select version();
+------------+
| version() |
+------------+
| 5.7.28-log |
+------------+
TIPS:如果是生产数据库,先备份后再操作。
登录从库mysql:
show slave status\G;
stop slave ;
set global read_only=0;
set global super_read_only=0;
exit;
执行upgrade
mysql_upgrade --host='127.0.0.1' --port=3306 --user='root' --password='xxxx'
mysql_upgrade: [Warning] Using a password on the command line interface can be insecure.
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
Checking system database.
mysql.columns_priv OK
mysql.db OK
mysql.engine_cost OK
mysql.event OK
mysql.func OK
mysql.general_log OK
mysql.gtid_executed OK
mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.ndb_binlog_index OK
mysql.plugin OK
mysql.proc OK
mysql.procs_priv OK
mysql.proxies_priv OK
mysql.server_cost OK
mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK
mysql.slow_log OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
Found outdated sys schema version 1.5.1.
Upgrading the sys schema.
Checking databases.
...
Upgrade process completed successfully.
Checking if update is needed.
登录MySQL,查看数据库是否正常
set global read_only=1;
set global super_read_only=1;
start slave ;
show slave status\G;
show processlist;