[ERROR] InnoDB: Could not find a valid tablespace file for


 

Tablespace Does Not Exist

With innodb_file_per_table enabled, the following message might occur if the .frm or .ibd files (or both) are missing:

If this occurs, try the following procedure to resolve the problem:

  1. Create a matching .frm file in some other database directory and copy it to the database directory where the orphan table is located.
  2. Issue DROP TABLE for the original table. That should successfully drop the table and InnoDB should print a warning to the error log that the .ibd file was missing.

上面大体意思是,比如testdb数据库缺少tbStudent表,那么你可以在别的或新建的数据库当中,创建tbStudent表,比如在SchoolDb数据库中创建的,那么在scholldb数据库的文件夹中会有tbStudent.frm和tbstudent.ibd文件,直接将tbStudent.frm拷贝到testdb数据库的testdb文件夹中,然后在testdb中使用drop table tbstudent命令,就能将不存在的清删掉了。

 

查询系统表,找到缺少的表:

于是自己写了个程序按照缺少的表名,并复制生成的表:

 

 

 

 

 

 

声明:本站内容来源于原创和互联网,尊重作者版权,转载请注明来源网址,欢迎收藏,谢谢!