ERROR 1016: Can't open file: 'db1.table1'. (errno: 1)

--err-log内容

051110 11:17:09  InnoDB: Started; log sequence number 0 43645
/usr/sbin/mysqld: ready for connections.
Version: '4.1.14-standard'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Edition - Standard (GPL)
051110 11:17:39  InnoDB: Error: table `db1/table1` does not exist in the InnoDB internal
InnoDB: data dictionary though MySQL is trying to drop it.
InnoDB: Have you copied the .frm file of the table to the
InnoDB: MySQL database directory from another database?
InnoDB: You can look for further help from
InnoDB: http://dev.mysql.com/doc/mysql/en/InnoDB_troubleshooting_datadict.html


[エラー原因]
MySQLを起動しようとしたら、サイズが違うぞエラーがInnoDBテーブルに対して出力されていた。
データを入れていないテーブルだったのでデータベースごと削除して、MySQLを再起動した。
再起動後、"DROP TABLE db1.table1;"をしたら、上記のエラー文言が出力された。
InnoDBテーブルをDROPせずにデータファイルを削除したために、アクセスできずエラーといわれている状態。


[対処]

  1. /etc/mysql.cnf に innodb_force_recovery = 1 を設定して再起動
  2. 再起動できなかった
  3. /etc/mysql.cnf に innodb_force_recovery = 2 を設定して再起動
  4. 再起動できた
  5. 問題のテーブルは見えないが、データベースは見える。
  6. DROP DATABASE db1;
  7. ファイルがあるからdb1ディレクトリは削除できない。というエラー(メッセージをメモし忘れた)
  8. cd データディレクトリ/db1
  9. rm -rf ./*
  10. DROP DATABASE db1;
  11. OK!
  12. #innodb_force_recovery = 2
  13. MySQL再起動
  14. CREATE DATABASE db1;
  15. OK!


[備考]
エラーログに参考URLが載っているが、MySQL全機能リファレンスのinnoDBクラッシュリカバリを参考にした