mysql升级后提示Please run mysql_upgrade
现象:
2020-12-10T05:16:25.210531Z 7003 [Warning] InnoDB: Table mysql/innodb_index_stats has length mismatch in the column name table_name. Please run mysql_upgrade
2020-12-10T05:16:25.211750Z 7003 [Warning] InnoDB: Table mysql/innodb_table_stats has length mismatch in the column name table_name. Please run mysql_upgrade
2020-12-10T05:16:25.211781Z 7003 [Warning] InnoDB: Table mysql/innodb_index_stats has length mismatch in the column name table_name. Please run mysql_upgrade
2020-12-10T05:16:25.212575Z 7003 [Warning] InnoDB: Table mysql/innodb_table_stats has length mismatch in the column name table_name. Please run mysql_upgrade
2020-12-10T05:16:25.212605Z 7003 [Warning] InnoDB: Table mysql/innodb_index_stats has length mismatch in the column name table_name. Please run mysql_upgrade
2020-12-10T05:16:25.213263Z 7003 [Warning] InnoDB: Table mysql/innodb_table_stats has length mismatch in the column name table_name. Please run mysql_upgrade
2020-12-10T05:16:25.213287Z 7003 [Warning] InnoDB: Table mysql/innodb_index_stats has length mismatch in the column name table_name. Please run mysql_upgrade
根据提示,可以看到是因为 mysql.innodb_table_stats 和 mysql.innodb_index_stats这张表table_name列问题。 那么对比下新老库看看吧。
新老数据正常表结构:mysql/innodb_index_stats和innodb_tables_stats中table_name字段
5.7.17:table_name varchar(64
) COLLATE utf8_bin NOT NULL,
5.7.24:table_name varchar(199
) COLLATE utf8_bin NOT NULL,
可以看出,5.7.24 版本上的 innodb_index_stats 和innodb_tables_stats 的 table_name
列,长度从64
变成了 199
,而我升级后的5.7.24中 table_name 还是64
,问题找到!
解决办法
执行下mysql_upgrade -u root -p –force
,然后重启下mysqld进程
即可
根据提示:是数据库innodb_table_stats 表中table_name一栏长度异常导致的。
1:执行mysl更新
mysql_upgrade --host=‘127.0.0.1’ --port=3306 --user=‘root’ --password=“root”
2:重启数据库mysql
service mysql restart