日期:2014-05-16  浏览次数:20396 次

InnoDB: Error: Table "mysql"."innodb_table_stats" not found.

1,Mysqldump的时候报错如下:

2014-05-05 14:12:37 7f004a9a2700 InnoDB: Error: Table "mysql"."innodb_table_stats" not found.

但是show tables我看这个表示存在的:


但是show create table innodb_index_stats;报错如下:

mysql>  show create table innodb_index_stats;
ERROR 1146 (42S02): Table'mysql.innodb_index_stats' doesn't exist
mysql>


2,估计是表坏了,去数据库服务器上面的mysql库的目录看下这些表的数据文件:

 

 

 

3,看到表的数据文件以及结构文件都存在

然后去找$MYSQL_HOME/share/mysql_system_tables.sql,search到建表语句

 

打开mysql_system_tables.sql,找到sql,然后执行:

mysql> CREATETABLE IF NOT EXISTS innodb_index_stats (
    ->         database_name                   VARCHAR(64) NOT NULL,
    ->         table_name                      VARCHAR(64) NOT NULL,
    ->         index_name                      VARCHAR(64) NOT NULL,
    ->         last_update                     TIMESTAMP NOT NULL NOTNULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    ->         stat_name                       VARCHAR(64) NOT NULL,
    ->         stat_value                      BIGINT UNSIGNED NOT NULL,
    ->         sample_size                     BIGINT UNSIGNED,
    ->         stat_description                VARCHAR(1024) NOT NULL,
    ->         PRIMARY KEY (database_name,table_name, index_name, stat_name)
    -> ) ENGINE=INNODB DEFAULT CHARSET=utf8COLLATE=utf8_bin STATS_PERSISTENT=0;
ERROR 1146(42S02): Table 'mysql.innodb_index_stats' doesn't exist
mysql>
mysql>

还报错Table 'mysql.innodb_index_stats' doesn'texist,可能是那个判断导致,去掉判断试试: