26

In mysqld.log I have thousands of lines like:

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

So, according to virtually every post on the matter (and error msg itself):

mysql_upgrade -u root -p

Enter password: 
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
Checking system database.
...

and all tables in all databases are like

...
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.
...

But, I am still getting the error in the log

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

The structure appears to be okay. Is there a config issue? Please advise.

The answer appears to be - reboot server. I do not have rights to do this, but after admin rebooted, issue appears to be resolved. Not sure why just rebooting MySQL did not fix?

Roy Hinkley
  • 459
  • 3
  • 8
  • 15

6 Answers6

13

Maybe this information is useful.

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

Note

This release includes a change to the innodb_index_stats and innodb_table_stats system tables. When upgrading to this release, be sure to run mysql_upgrade in order to include these changes.

Giacomo1968
  • 226
  • 2
  • 17
Chrysweel
  • 239
  • 2
  • 2
10

Do you have any clue what is going on when the warning is being generated? It sounds like some form of version mismatch. Do you have any plug ins?

Please file a bug at bugs.mysql.com.

Meanwhile, do this:

USE mysql;
SHOW CREATE TABLE innodb_index_stats ;

Check, in particular, the definition of table_name. It used to be this:

`table_name` varchar(64) COLLATE utf8_bin NOT NULL,

But in MySQL 8.0 it changed to:

`table_name` varchar(199) COLLATE utf8_bin NOT NULL,

If it is still 64, rerun what mysql_update should have done, by doing

ALTER TABLE innodb_index_stats
    MODIFY   `table_name` varchar(199) COLLATE utf8_bin NOT NULL;

Ditto for innodb_table_stats.

See also the comment by Giacomo1968

Rick James
  • 80,479
  • 5
  • 52
  • 119
5

In command line:

  1. Run mysql_upgrade --user=your_user_name --password
  2. Enter password.

You may have to use --force if the database have already been upgraded and something went wrong (which is probably the case if you are here). Don't worry, mysql_upgrade will tell you about this and as a result you just have to re-run it with --force.

That's it.

TitanFighter
  • 151
  • 1
  • 3
2

I just ran into a similar problem on a MySQL 5.7.40 test system that barely gets used. The overall system might have crashed and screwed up a core mysql DB table. Saw the same “…has length mismatch in the column name table_name…” errors in the mysqld.log; hundreds if not thousands of that error being logged.

I tried to run mysql_upgrade as the error advises but was getting errors along the lines of the root user had no access despite the fact I could use the exact same credentials to get into MySQL and see that table_name was set as varchar(64) as it should be as explained in Rick James’s answer.

`table_name` varchar(64) COLLATE utf8_bin NOT NULL,

Not wanting to purge and re-install MySQL I did the following and it cleared up the issue. The key here is you have another system available that is running the same version of MySQL as the system that has the issues is running.

Go to that other system with the similar MySQL install, and dump these mysql tables into .sql file named mysql_innodb_tables.sql like this

TABLELIST="innodb_index_stats"
TABLELIST="${TABLELIST} innodb_table_stats"
TABLELIST="${TABLELIST} engine_cost"
TABLELIST="${TABLELIST} gtid_executed"
TABLELIST="${TABLELIST} help_category"
TABLELIST="${TABLELIST} help_keyword"
TABLELIST="${TABLELIST} help_relation"
TABLELIST="${TABLELIST} help_topic"
TABLELIST="${TABLELIST} slave_master_info"
TABLELIST="${TABLELIST} slave_relay_log_info"
TABLELIST="${TABLELIST} slave_worker_info"
TABLELIST="${TABLELIST} plugin"
TABLELIST="${TABLELIST} server_cost"
TABLELIST="${TABLELIST} servers"
TABLELIST="${TABLELIST} time_zone"
TABLELIST="${TABLELIST} time_zone_leap_second"
TABLELIST="${TABLELIST} time_zone_name"
TABLELIST="${TABLELIST} time_zone_transition_type"
mysqldump -uroot -p mysql ${TABLELIST} > mysql_innodb_tables.sql

Then copy that mysql_innodb_tables.sql file to the system that needs repair, and import that SQL as root like this:

mysql -u root -p mysql < mysql_innodb_tables.sql

Restart MySQL and the repairs should now be in place and the mysqld.log should stop filling up with those “…has length mismatch in the column name table_name…” errors.

Giacomo1968
  • 226
  • 2
  • 17
0

If you run your app on your local system and use MAMP so you can run this command to solve the problem:

/Applications/MAMP/Library/bin/mysql_upgrade --host=localhost -uroot -proot
Giacomo1968
  • 226
  • 2
  • 17
0

Somethimes is necesary modify 2 tables 'innodb_index_stats' and 'innodb_table_stats'.

query1

ALTER TABLE innodb_index_stats
    MODIFY   `table_name` varchar(199) COLLATE utf8_bin NOT NULL;

query2

ALTER TABLE innodb_table_stats
    MODIFY   `table_name` varchar(199) COLLATE utf8_bin NOT NULL;