Mysql关于InnoDB表误删除掉.frm文件无法删除也无法创建的情况

   最近在数据库转移,库中有的表需要用到事务,所以引擎设置成了InnoDB,无意间把表的frm文件给删除了,想要删除重建提示错误,直接创建也会提示此表已经存在,是删也删不掉,建也建不了,网上查了下说是因为表在 innodb 内部数据字典中已存在,没有相对应的 .frm 文件,在 innodb 的数据文件中就形成了一个孤表(orphaned table)。

   经查询在下面的文章中找到了答案:

table test/parent already exists in innodb internal data dictionary.
have you deleted the .frm file and not used drop table? 
have you used drop database for innodb tables in mysql version <= 3.23.43? 
see the restrictions section of the innodb manual.
you can drop the orphaned table inside innodb creating an innodb table with the same name in another database and moving the .frm file to the current database. 
then mysql thinks the table exists, and drop table will innodb: succeed.

   意思就是说:你可以通过在另外一个数据库中创建一个相同名字的innodb表,并把.frm拷贝到这个数据库目录下,数据库就会认为这个表存在,再执行drop table就可以删除掉了。

by 雪洁 2013-06-26 06:25:14 14551 views

4 Comments

雪洁 2018-11-23 14:11:34
谢谢支持!!!
牢记圣光 2019-12-12 13:31:38
谢谢老师啦,鼓捣了一下午,还是您的答案帮助了我!
雪洁 2019-12-12 13:31:56
不客气~
xu 2019-12-12 13:32:26
谢楼主解惑
我来说几句

相关文章