MySQL错误日志提示innodb_table_stats和innodb_index_stats不存在故障处理

时间:2022-12-15 08:23:34

查看MySQL error日志,发现有如下报错

 7efbc586f700 InnoDB: Error: Table "mysql"."innodb_table_stats" not found.
2016-05-22 12:04:11 7efbc586f700 InnoDB: Error: Table "mysql"."innodb_table_stats" not found.
2016-05-22 12:04:11 7efbc586f700 InnoDB: Error: Table "mysql"."innodb_table_stats" not found.
2016-05-22 12:04:11 7efbc586f700 InnoDB: Error: Fetch of persistent statistics requested for table "alog"."wmp_sale_order_0126" but the required system tables mysql.innodb_table_stats and mysql.innodb_index_stats are not present or have unexpected structure. Using transient stats instead.
2016-05-22 12:04:21 7efbbdffb700 InnoDB: Error: Table "mysql"."innodb_table_stats" not found.
2016-05-22 12:04:21 7efbbdffb700 InnoDB: Recalculation of persistent statistics requested for table "alog"."wmp_sale_order_0126" but the required persistent statistics storage is not present or is corrupted. Using transient stats instead.

造成这个原因的问题可能是在初始化的过程中,删掉了ibdata1的文件导致,处理的方法

1.删除上述系统表
drop table mysql.innodb_index_stats;
drop table mysql.innodb_table_stats;
2 /etc/init.d/mysqld stop
3 cd /data/3306/data/mysql/
4 rm -rf innodb_index_stats* innodb_table_stats*
5 /etc/init.d/mysqld start
6 mysql> use mysql
Database changed
mysql> CREATE TABLE `innodb_index_stats` (
    ->   `database_name` varchar(64) COLLATE utf8_bin NOT NULL,
    ->   `table_name` varchar(64) COLLATE utf8_bin NOT NULL,
    ->   `index_name` varchar(64) COLLATE utf8_bin NOT NULL,
    ->   `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    ->   `stat_name` varchar(64) COLLATE utf8_bin NOT NULL,
    ->   `stat_value` bigint(20) unsigned NOT NULL,
    ->   `sample_size` bigint(20) unsigned DEFAULT NULL,
    ->   `stat_description` varchar(1024) COLLATE utf8_bin NOT NULL,
    ->   PRIMARY KEY (`database_name`,`table_name`,`index_name`,`stat_name`)
    -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;
Query OK, 0 rows affected (0.02 sec)

mysql> CREATE TABLE `innodb_table_stats` (
    ->   `database_name` varchar(64) COLLATE utf8_bin NOT NULL,
    ->   `table_name` varchar(64) COLLATE utf8_bin NOT NULL,
    ->   `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    ->   `n_rows` bigint(20) unsigned NOT NULL,
    ->   `clustered_index_size` bigint(20) unsigned NOT NULL,
    ->   `sum_of_other_index_sizes` bigint(20) unsigned NOT NULL,
    ->   PRIMARY KEY (`database_name`,`table_name`)
    -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;

问题解决