溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Mysql 5.7.20中mysql innodb系統(tǒng)表?yè)p壞應(yīng)該如何處理

發(fā)布時(shí)間:2020-06-01 17:20:30 來(lái)源:網(wǎng)絡(luò) 閱讀:502 作者:三月 欄目:MySQL數(shù)據(jù)庫(kù)

本文主要給大家介紹Mysql 5.7.20中mysql innodb系統(tǒng)表?yè)p壞應(yīng)該如何處理,文章內(nèi)容都是筆者用心摘選和編輯的,具有一定的針對(duì)性,對(duì)大家的參考意義還是比較大的,下面跟筆者一起了解下Mysql 5.7.20中mysql innodb系統(tǒng)表?yè)p壞應(yīng)該如何處理吧。

早上上班后,mysql云服務(wù)器遇到點(diǎn)小問(wèn)題,在排查故障過(guò)程查看mysql錯(cuò)誤日志過(guò)程中發(fā)現(xiàn)有幾個(gè)innodb 表無(wú)法打開(kāi),使用desc查看有關(guān)表的表結(jié)構(gòu)提示表不存在,show tables 可以查到一下五個(gè)表,以下是具體的報(bào)錯(cuò)信息:

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.

網(wǎng)上查了下資料,問(wèn)題的問(wèn)題產(chǎn)生原因:數(shù)據(jù)庫(kù)打開(kāi)這幾張表的默認(rèn)引擎為MyISAM,但是這幾張表在建表時(shí)的引擎為INNODB;從而引起mysql報(bào)錯(cuò)

msyql在5.6版本引入了以下五個(gè)表

innodb_index_stats,

innodb_tables_stats,

slave_master_info,

slave_relay_log_info,

slave_worker_info

定位了問(wèn)題原因后,那我們就開(kāi)始著手準(zhǔn)備解決以上存在的問(wèn)題,解決的思路是,刪除有問(wèn)題的表和數(shù)據(jù)文件,使用安裝msyql的官方自帶建表腳本,重新創(chuàng)建有問(wèn)題的5個(gè)表。

操作步驟如下

1,登錄數(shù)據(jù)庫(kù)執(zhí)行以下操作,sql語(yǔ)句加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; 驗(yàn)證執(zhí)行結(jié)果,以上表是否已刪除

2,停止mysql數(shù)據(jù)庫(kù)服務(wù),并進(jìn)入到數(shù)據(jù)庫(kù)數(shù)據(jù)文件所在目錄,刪除上面5個(gè)表所對(duì)應(yīng)的idb文件,linux系統(tǒng)環(huán)境,我的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服務(wù),并重建被刪除的五個(gè)表的表結(jié)構(gòu),建表腳本在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個(gè)表已恢復(fù)

Mysql 5.7.20中mysql innodb系統(tǒng)表?yè)p壞應(yīng)該如何處理

mysql> DESC innodb_table_stats ;

Mysql 5.7.20中mysql innodb系統(tǒng)表?yè)p壞應(yīng)該如何處理

其余四個(gè)表結(jié)構(gòu)的查看過(guò)程略,

在查看mysql的錯(cuò)誤日志,報(bào)錯(cuò)信息沒(méi)有了

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

Mysql 5.7.20中mysql innodb系統(tǒng)表?yè)p壞應(yīng)該如何處理

看完以上關(guān)于Mysql 5.7.20中mysql innodb系統(tǒng)表?yè)p壞應(yīng)該如何處理,很多讀者朋友肯定多少有一定的了解,如需獲取更多的行業(yè)知識(shí)信息 ,可以持續(xù)關(guān)注我們的行業(yè)資訊欄目的。 

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI