报错:Table mysql/innodb_table_stats has length mismatch in the column name table_name.

2020年1月8日 | 分类: 【技术】

MySQL日志路径:/var/log/mysql/error.log

出现大量报错:

2020-01-07T23:40:38.115341Z 0 [Warning] InnoDB: Table mysql/innodb_table_stats has length mismatch in the column name table_name.  Please run mysql_upgrade
2020-01-07T23:40:38.115379Z 0 [Warning] InnoDB: Table mysql/innodb_index_stats has length mismatch in the column name table_name.  Please run mysql_upgrade

参考:https://www.cnblogs.com/gaogao67/p/11715700.html
参考:https://blog.csdn.net/hnyxwl_liufan/article/details/90017390
参考:https://blog.csdn.net/hanzheng260561728/article/details/102928671

原因:5.7.24 版本上的 innodb_index_stats 和innodb_tables_stats 的 table_name 列,长度从64 变成了 199,而原 table_name 还是 64。

方法:在 shell 命令行(不是 mysql 命令行)

mysql_upgrade --host='localhost' --port=3358 --user='root' --password="PASSWORD"

输出:

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.user                                         OK
Found outdated sys schema version 1.5.1.
Upgrading the sys schema.
Checking databases.
dev.domains                          OK
...
dev.whoislog                                OK
Upgrade process completed successfully.
Checking if update is needed.

重启 mysql 服务,生效配置:

systemctl restart mysqld