Mysql

表 mysql/innodb_index_stats 的列名 table_name 的長度不匹配。請執行 mysql_upgrade

  • January 5, 2022

mysqld.log我有成千上萬行,例如:

Table mysql/innodb_index_stats has length mismatch in the column name table_name.  Please run mysql_upgrade

因此,根據幾乎所有關於此事的文章(以及錯誤消息本身):

mysql_upgrade -u root -p

Enter password: 
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
The sys schema is already up to date (version 1.5.1).
Checking databases.
...

但是,我仍然在日誌中收到錯誤

2019-01-27T18:37:15.304587Z 66190 [Warning] InnoDB: Table mysql/innodb_table_stats has length mismatch in the column name table_name.  Please run mysql_upgrade
2019-01-27T18:37:15.304620Z 66190 [Warning] InnoDB: Table mysql/innodb_index_stats has length mismatch in the column name table_name.  Please run mysql_upgrade
2019-01-27T18:37:15.304684Z 66190 [Warning] InnoDB: Table mysql/innodb_table_stats has length mismatch in the column name table_name.  Please run mysql_upgrade
2019-01-27T18:37:15.304707Z 66190 [Warning] InnoDB: Table mysql/innodb_index_stats has length mismatch in the column name table_name.  Please run mysql_upgrade

結構似乎還可以。有配置問題嗎?請指教。

答案似乎是 - 重新啟動伺服器。我無權執行此操作,但管理員重新啟動後,問題似乎已解決。不知道為什麼只是重新啟動 MySQL 沒有修復?

也許這些資訊很有用。

https://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-23.html

筆記

此版本包括對 innodb_index_stats 和 innodb_table_stats 系統表的更改。升級到此版本時,請務必執行 mysql_upgrade 以包含這些更改。

引用自:https://dba.stackexchange.com/questions/228203