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

mysql日志报错:

 InnoDB: Error: Table "mysql"."innodb_table_stats" not found.
2019-08-08 14:02:43 7f29cef3a700 InnoDB: Error: Fetch of persistent statistics requested for table "hbevent"."events" but the required system tables mysql.inno
db_table_stats and mysql.innodb_index_stats are not present or have unexpected structure. Using transient stats instead.

 

 

百度后说是缺少五个innodb存储引擎的系统表,于是跟正常的服务器去对比,发现如下:

图一

图二

发现确实少了五个表。

 

但是去mysql数据库目录下查看存在.ibd文件,但是没有.frm文件。。。。。。

于是决定恢复.ibd文件,首先去mysql的安装目录的share文件夹下获取这五个系统表的建表语句,先抽取innodb_table_stats的建表语句,建表前先将目录原有的innodb_table_stats.ibd文件mv为innodb_table_stats.ibd.bak文件,执行创建脚本

生成innodb_table_stats表后,alter table innodb_table_stats discard tablespace;

然后将生成的innodb_table_stats.ibd删除,mv   innodb_table_stats.ibd.bak   innodb_table_stats.ibd;

alter table innodb_table_stats import tablespace;

等了好久成功了,但是从库报错,因为从库没有mv   innodb_table_stats.ibd.bak   innodb_table_stats.ibd操作,也没有 innodb_table_stats.ibd文件,后来通过在从库上stop slave;SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;(小写的不好使,必须大写,不知道为啥)跳过这个同步。

觉得这样操作太复杂,又看了下主库的报错日志:

2019-08-08 16:41:09 10682 [ERROR] InnoDB: The file './mysql/slave_relay_log_info.ibd' already exists though the corresponding table did not exist in the InnoDB
 data dictionary. Have you moved InnoDB .ibd files around without using the SQL commands DISCARD TABLESPACE and IMPORT TABLESPACE, or did mysqld crash in the m
iddle of CREATE TABLE? You can resolve the problem by removing the file './mysql/slave_relay_log_info.ibd' under the 'datadir' of MySQL.
2019-08-08 16:41:09 7f29cdba2700  InnoDB: Operating system error number 17 in a file operation.

决定将这5个表的ibd文件直接变成.bak,直接在主库上use mysql; source   /路径/五个表的脚本.sql

成功执行。

。。。。。开始恢复的innodb_table_stats表我并没有从中查到数据,所以直接重建五个表吧

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值