删除.frm文件后清除错误

时间:2014-01-08 16:33:52

标签: mysql

我不小心删除了测试表的.frm文件。问题是我不能删除此表并将其从information_schema中删除。

select * from information_schema.tables where table_name like 'testtesttest';
+---------------+--------------+--------------+------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------+-------------+------------+-----------------+----------+----------------+----------------------------------------------------------+
| TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME   | TABLE_TYPE | ENGINE | VERSION | ROW_FORMAT | TABLE_ROWS | AVG_ROW_LENGTH | DATA_LENGTH | MAX_DATA_LENGTH | INDEX_LENGTH | DATA_FREE | AUTO_INCREMENT | CREATE_TIME | UPDATE_TIME | CHECK_TIME | TABLE_COLLATION | CHECKSUM | CREATE_OPTIONS | TABLE_COMMENT                                            |
+---------------+--------------+--------------+------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------+-------------+------------+-----------------+----------+----------------+----------------------------------------------------------+
| def           | report       | testtesttest | BASE TABLE | NULL   |    NULL | NULL       |       NULL |           NULL |        NULL |            NULL |         NULL |      NULL |           NULL | NULL        | NULL        | NULL       | NULL            |     NULL | NULL           | Can't find file: './report/testtesttest.frm' (errno: 13) |
+---------------+--------------+--------------+------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------+-------------+------------+-----------------+----------+----------------+----------------------------------------------------------+

drop table report.testtesttest;
ERROR 1051 (42S02): Unknown table 'testtesttest'

有没有办法告诉mysql这样的表不再存在?

1 个答案:

答案 0 :(得分:3)

看起来以下步骤有帮助:

  1. touch /var/lib/mysql/report/testtesttest.{frm,ibd}
  2. chown mysql:mysql /var/lib/mysql/report/testtesttest.frm
  3. 重启mysql
  4. drop table report.testtesttest;