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系统表损坏应该如何处理,很多读者朋友肯定多少有一定的了解,如需获取更多的行业知识信息 ,可以持续关注我们的行业资讯栏目的。 

相关内容

热门资讯

“AI+课程”如何变身“微创课... 当前,以大模型、智能算法和数据技术为核心的AI技术正在深刻改变劳动力市场,同时影响制造业、服务业及知...
“点热成电”,挖掘能源金矿 “十五五”规划纲要提出,深入实施能源安全新战略,加快构建清洁低碳安全高效的新型能源体系,建设能源强国...
新能源车企激战大电量时代 “量... 时报财经图库/供图 证券时报记者 叶玲珍 作为车企角逐的主战场,电池容量军备竞赛日趋白热化。中国汽车...
以方透露内塔尼亚胡曾秘访阿联酋... 以色列方面5月13日透露,以总理内塔尼亚胡在以色列对伊朗发动大规模军事行动期间曾秘密访问阿联酋,并称...
英伟达、谷歌、苹果均创市值历史... 【CNMO科技消息】5月14日,CNMO科技注意到,美东时间周三,美股三大指数涨跌不一,纳指和标普5...
商业化探索持续深入 “AI+教... 来源:滚动播报 (来源:经济参考报) 人工智能通识课堂上,教师发出指令几分钟后,学生手绘的卡通人物就...
偷拍男子是否会被清出公务员拟录... 近日,南京审计大学一名在校研究生顾某某因涉嫌偷拍女生隐私,引发关注。顾某某已被国家税务总局江苏省税务...
乌克兰首都基辅传出爆炸声 △乌克兰首都基辅(资料图)当地时间14日,乌克兰首都基辅传出爆炸声,此前基辅拉响防空警报。(总台记者...
移动空调制冷一会就停止了 原因可能是空调正在开启启动模式,移动空调存在逐步启动模式,在空调开启过程中会逐步启动保证空调的正常运...
排水管怎么安装 首先需关闭上水阀,然后将软管用扳手拧下来装上三通,注意需要按一个内部带丝扣的一面,然后在三通上接上原...