begemotv2718
begemotv2718

Reputation: 868

Clear error after removing .frm file

I have accidentally deleted a .frm file for a test table. The problem is that I can not drop this table and remove it from 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'

Is there a way to tell mysql that such a table no longer exists?

Upvotes: 2

Views: 954

Answers (1)

begemotv2718
begemotv2718

Reputation: 868

Looks like that the following steps help:

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

Upvotes: 3

Related Questions