Mysql 5.7.20中mysql innodb系统表损坏应该如何处理
admin
2023-05-08 00:41:17
0

本文主要给大家介绍Mysql 5.7.20中mysql innodb系统表损坏应该如何处理,文章内容都是笔者用心摘选和编辑的,具有一定的针对性,对大家的参考意义还是比较大的,下面跟笔者一起了解下Mysql 5.7.20中mysql innodb系统表损坏应该如何处理吧。

早上上班后,mysql云服务器遇到点小问题,在排查故障过程查看mysql错误日志过程中发现有几个innodb 表无法打开,使用desc查看有关表的表结构提示表不存在,show tables 可以查到一下五个表,以下是具体的报错信息:

2018-01-12 09:17:41 17235 [Warning] InnoDB: Cannot open table mysql/innodb_index_stats from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.

2018-01-12 09:17:41 17235 [Warning] InnoDB: Cannot open table mysql/innodb_table_stats from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.

2018-01-12 09:17:41 17235 [Warning] InnoDB: Cannot open table mysql/slave_master_info from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.

2018-01-12 09:17:41 17235 [Warning] InnoDB: Cannot open table mysql/slave_relay_log_info from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.

2018-01-12 09:17:41 17235 [Warning] InnoDB: Cannot open table mysql/slave_worker_info from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.

网上查了下资料,问题的问题产生原因:数据库打开这几张表的默认引擎为MyISAM,但是这几张表在建表时的引擎为INNODB;从而引起mysql报错

msyql在5.6版本引入了以下五个表

innodb_index_stats,

innodb_tables_stats,

slave_master_info,

slave_relay_log_info,

slave_worker_info

定位了问题原因后,那我们就开始着手准备解决以上存在的问题,解决的思路是,删除有问题的表和数据文件,使用安装msyql的官方自带建表脚本,重新创建有问题的5个表。

操作步骤如下

1,登录数据库执行以下操作,sql语句加if 判断,如果表存在,则删除

mysql> use mysql;

mysql> drop table if exists innodb_index_stats;

mysql> drop table if exists innodb_table_stats;

mysql> drop table if exists slave_master_info;

mysql> drop table if exists slave_relay_log_info;

mysql> drop table if exists slave_worker_info;

mysql> show tables; 验证执行结果,以上表是否已删除

2,停止mysql数据库服务,并进入到数据库数据文件所在目录,删除上面5个表所对应的idb文件,linux系统环境,我的msyql的basedir目录是 /usr/local/mysql/

datadir目录是/data/mysql/var/mysql/

[root@mysql5 ]# systemctl restart stop

[root@sql5 root]# cd /data/mysql/var/mysql/

[root@sql5 mysql]# ls -l *.ibd

-rw-rw---- 1 mysql mysql 98304 3月   7 2017 innodb_index_stats.ibd

-rw-rw---- 1 mysql mysql 98304 3月   7 2017 innodb_table_stats.ibd

-rw-rw---- 1 mysql mysql 98304 3月   7 2017 slave_master_info.ibd

-rw-rw---- 1 mysql mysql 98304 3月   7 2017 slave_relay_log_info.ibd

-rw-rw---- 1 mysql mysql 98304 3月   7 2017 slave_worker_info.ibd

[root@sql5 mysql]#rm -rf *.ibd

3,重启mysql服务,并重建被删除的五个表的表结构,建表脚本在mysql软件的安装目录的share目录下或者mysql的安装包的script目录下

[root@mysql5 mysql]# cd /usr/local/mysql/share/

[root@mysql5 share]# ls -l *.sql  //查看所有的建表脚本

-rw-r--r--. 1 root root 932622 9月  13 23:56 fill_help_tables.sql

-rw-r--r--. 1 root root   3999 9月  13 23:48 innodb_memcached_config.sql

-rw-r--r--. 1 root root   1812 11月  7 11:42 install_rewriter.sql

-rw-r--r--. 1 root root   1760 9月  13 23:48 mysql_security_commands.sql

-rw-r--r--. 1 root root 287110 9月  13 23:48 mysql_sys_schema.sql

-rw-r--r--. 1 root root    811 9月  13 23:48 mysql_system_tables_data.sql

-rw-r--r--. 1 root root 154624 9月  13 23:48 mysql_system_tables.sql

-rw-r--r--. 1 root root  10410 9月  13 23:48 mysql_test_data_timezone.sql

-rw-r--r--. 1 root root    834 11月  7 11:42 uninstall_rewriter.sql

[root@mysql5 share]# systemctl restart mysqld

mysql> USE MYSQL;

mysql> source /usr/local/mysql/share/innodb_memcached_config.sql

mysql> show tables; 删除的5个表已恢复

Mysql 5.7.20中mysql innodb系统表损坏应该如何处理

mysql> DESC innodb_table_stats ;

Mysql 5.7.20中mysql innodb系统表损坏应该如何处理

其余四个表结构的查看过程略,

在查看mysql的错误日志,报错信息没有了

[root@mysql5 share]# tail /data/mysql/var/mysqld.err

Mysql 5.7.20中mysql innodb系统表损坏应该如何处理

看完以上关于Mysql 5.7.20中mysql innodb系统表损坏应该如何处理,很多读者朋友肯定多少有一定的了解,如需获取更多的行业知识信息 ,可以持续关注我们的行业资讯栏目的。 

相关内容

热门资讯

Google在港推出AI代理G... 观点网讯:7月29日,Google在香港推出AI代理Gemini Spark,该代理可全天候在后台运...
5G+165Hz!联想新品官宣... 近两年来,小屏平板一直是比较有趣的一个品类。 不同于大平板注重效率、手机追求万能的特点,拯救者Y70...
原创 马... 马斯克又出来了。这次说2036年钱就没用了。 理由是人工智能加机器人,东西多到你用不完,还拿钱干嘛...
美的集团:我国智能家居互联互通... IT之家 7 月 30 日消息,美的集团今日发布公告,7 月 21 日至 23 日,智能家居互联互通...
华为新款MatePad Pro... 【CNMO科技消息】7月30日,@华为终端 官宣全新旗舰平板华为MatePad Pro。 新款华为...
从实验室到实景验证:6G光子太... 全息通信是第六代移动通信(6G)的典型应用场景之一,旨在通过融合无线传输与全息三维成像技术,实现超大...
从“能对话”到“能干活”——人... 【经济界面】 光明日报记者 刘坤 李晓东 周洪双 人工智能(AI)眼镜化身为个人“助理”,实时进行...
【全新发布】UminiP Pr... (来源:洲明科技)
日本通过“H3火箭8号”发射失... △H3火箭(资料图) 日本文部科学省30日召开关于去年“H3火箭8号”发射失败的会议。会议通过的最终...
互联网巨头抢滩健康硬件,上游芯... 封面新闻记者 付文超 当下,互联网巨头对健康硬件的押注,正在成为产业现实,加速拉动整个产业链步入新一...