咨询微信: dbservice1234 7 x 24 在线支持!

    你在这里

    • You are here:
    • 首页 > 博客 > PDSERVICE的博客 > MySQL InnoDB テーブルが壊れて、このようなエラが現れた: “MySQL is trying to open a table handle but the .ibd file for table ### does not exist”

MySQL InnoDB テーブルが壊れて、このようなエラが現れた: “MySQL is trying to open a table handle but the .ibd file for table ### does not exist”

MySQL InnoDB テーブルが壊れて、このようなエラが現れた: “MySQL is trying to open a table handle but the .ibd file for table ### does not exist”

MySQL InnoDB テーブルが壊れて、このようなエラが現れた: “MySQL is trying to open a table handle but the .ibd file for table ### does not exist”

 

プロのOracle Databaseの復旧サービスを提供

携帯番号: +86 13764045638 メール:service@parnassusdata.com

 

この記事で

症状

原因

解决策

方法

 

適用範囲:

MySQLサーバのバージョン4.0以上
この資料の情報は、すべてのプラットフォームに適用されます。

 

症状

test.t1をアクセスしてみると,以下のエラが現れる:

150512 16:30:01 [ERROR] MySQL is trying to open a table handle but the .ibd

file for

table te st/t1 does not exist.

Have you deleted the .ibd fil e from the database directory under

the MySQL datadir, or have you used DISCARD TABLESPACE?

See http://dev.mysql.com/doc/refman/5.1/en/innodb‐troubl eshooting.html

how you can resolve the problem.

 

原因

このエラの原因はテーブルt1の.ibdファイルがないからである。これはどんな文でもテーブルT1に対して実行出来ない。

エラ自身でそしてそのファイルがまだ存在しているかを確認する:

shell> ls ‐lahR /var/lib/mysql/

/var/lib/mysql/test:

total 21G

drwx‐‐‐‐‐‐ 2 mysql mysql 32K may 12 03:55 .

drwxr‐xr‐x 7 mysql mysql 4,0K nov 10 2014 ..

‐rw‐rw‐‐‐‐ 1 mysql mysql 8,6K may 12 03:16 t.frm

‐rw‐rw‐‐‐‐ 1 mysql mysql 20M may 12 13:37 t.ibd

‐rw‐rw‐‐‐‐ 1 mysql mysql 8,5K ago 10 2014 t1.frm

‐rw‐rw‐‐‐‐ 1 mysql mysql 8,5K may 12 03:16 t2.frm

‐rw‐rw‐‐‐‐ 1 mysql mysql 128K may 12 03:16 t2.ibd

もう一度MySQLエラログを確認して、エラが現れるときに、つまり、truncate tableを実行しているときに見られる。その文は自身の.ibdファイルを再構造できないから、ファイルがなくした:

140810 5:05:03 InnoDB: TRUNCATE TABLE test/t1 failed to create a new

tablespace

 

解决策

テーブルを再構造する:

  1. Drop table:

mysql> DROP TABLE test.t1;

The following error may be seen in the error log afterwards, but it’s basically saying the

tablespace was still present in InnoDB Data Dictionary and that eventually was removed:

150513 14:49:08 InnoDB: Error: table ‘test/t1’

InnoDB: in InnoDB data dictionary has tables pace id 607381,

InnoDB: but tablespace with that id or name does not exist. Have

InnoDB: you deleted or moved .ibd files?

InnoDB: This may also be a table created with CREATE TEMPORARY TABLE

InnoDB: whose .ibd and .frm files MySQL automatically removed, but t he

InnoDB: table still exists in the InnoDB internal data dictionary.

InnoDB: Please refer to

InnoDB: http://dev.mysql .com/doc/refman/5.1/en/innodb‐troubleshootingdatadict.

html

InnoDB: fo r how to resolve the issue.

InnoDB: We removed now the InnoDB int ernal data dictionary entry

InnoDB: of table `test`.`t1`.

 

  1. 再びCreate table
  2. テーブルのアクセスをテストして、実行できるかを確かめる。 (ex: optimize table)

mysql> OPTIMIZE TABLE test.t1;