找不到的幽灵表

老钱包 2013-08-02 04:40:24
新建立一个测试库
mysql> create database t2;
mysql> use t2;

mysql> create table if not exists testt1(id int(4),content varchar(20));
ERROR 1050 (42S01): Table '`t2`.`testt1`' already exists

结果发生了幽灵表的问题
mysql> create table if not exists testt1(id int(4),content varchar(20));
ERROR 1050 (42S01): Table '`t2`.`testt1`' already exists

mysql> insert into testt1 values(0005,"laugh ge");
ERROR 1146 (42S02): Table 't2.testt1' doesn't exist

mysql> show tables;
Empty set (0.00 sec)

因为之前使用直接删掉数据库文件夹的方式,将这个t2库干掉了。
搜了一下 information_schema 这个库

select * from TABLES where TABLE_SCHEMA='t2' limit 5;
结果是空!

求问这个问题如何处理?
...全文
528 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
rucypli 2013-08-02
  • 打赏
  • 举报
回复
把库删掉重新建立
ACMAIN_CHM 2013-08-02
  • 打赏
  • 举报
回复
引用
15.2.17.1. InnoDB数据词典操作错误诊断和排除 表的一个特殊问题是MySQL服务器以.frm文件来保存数据词典信息,它被放在数据库目录,然而InnoDB也存储信息到表空间文件里它自己的数据词典里。如果你把.frm文件移来移去 ;或者,如果服务器在数据词典操作的中间崩溃,.frm文件可能结束与InnoDB内部数据词典的同步。 一个不同步的数据词典的症状是CREATE TABLE语句失败。如果发生这种情况,你应该查看服务器的错误日志。如果日志说表已经存在于InnoDB内部数据词典当中,你在InnoDB表空间文件内有一个孤表,它没有对应的.frm文件。错误信息看起来象如下的: InnoDB: Error: table test/parent already exists in InnoDB internal InnoDB: data dictionary. Have you deleted the .frm file InnoDB: and not used DROP TABLE? Have you used DROP DATABASE InnoDB: for InnoDB tables in MySQL version <= 3.23.43? InnoDB: See the Restrictions section of the InnoDB manual. InnoDB: You can drop the orphaned table inside InnoDB by InnoDB: creating an InnoDB table with the same name in another InnoDB: database and moving the .frm file to the current database. InnoDB: Then MySQL thinks the table exists, and DROP TABLE will InnoDB: succeed. 你可以按照错误日志里给的指示移除一个孤表。如果还是不能成功地使用DROP TABLE,问题可能是因为在mysql客户端里的名字完成。要解决这个问题,用--disable-auto-rehash选项来启动mysql客户端并再次尝试DROP TABLE 。(有名字完成打开着,mysql试着构建个表名字的列表,当一个正如描述的问题存在之时,这个列表就不起作用)。 不同步数据词典的另一个“同义词”是MySQL打印一个不能打开.InnoDB文件的错误: ERROR 1016: Can't open file: 'child2.InnoDB'. (errno: 1) 在错误日志你可以发现一个类似于此的信息: InnoDB: Cannot find table test/child2 from the internal data dictionary InnoDB: of InnoDB though the .frm file for the table exists. Maybe you InnoDB: have deleted and recreated InnoDB data files but have forgotten InnoDB: to delete the corresponding .frm files of InnoDB tables? 这意味这有一个孤单的.frm文件,在InnoDB内没有相对应的表。你可以通过手动删除来移除这个孤单的.frm文件。 如果MySQL在一个 ALTER TABLE操作的中间崩溃,你可以用InnoDB表空间内临时孤表来结束。你可以用innodb_table_monitor看一个列出的表,名为#sql-...。如果你把表的名字包在`(backticks)里,你可以在名字包含“#”字符的表上执行SQL语句。因此,你可以用前述的的方法象移除其它孤表一样移除这样一个孤表。注意,要在Unix外壳里复制或重命名一个文件,如果文件名包含"#"字符,你需要把文件名放在双引号里。
.

56,687

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧