開発したアプリなど一覧

MySQL から table is marked as crashed and last (automatic?) repair failed というエラーが出たので対処した

アフィリエイトリンクを含む場合があります

先日ある Web サイトにアクセスした際、データベースの中身が一切読み込めない現象が発生した。MySQL 自体は正常に動作しているようで Web サイト自体はエラーが出ずに動き続けているという異常な状態であった。

MySQL のエラーメッセージを確認したところ、以下のようなエラーが発生していた。

[ERROR] /usr/sbin/mysqld: table './example/foobar' is marked as crashed and last (automatic?) repair failed

example データベースの foobar テーブルが壊れて自動修復も上手く動かない状態のようだ。このような状態の場合には、MySQL にアクセスして repair コマンドを実行すれば直る可能性があるようだ。試してみよう。

mysql> mysql> use example Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A

Database changed

まずは check table 状態を確認してみる。

mysql> check table foobars quick; +-----------------+-------+----------+---------------------------------------------------+ | Table | Op | Msg_type | Msg_text | +-----------------+-------+----------+---------------------------------------------------+ | example.foobars | check | warning | Table is marked as crashed and last repair failed | | example.foobars | check | status | OK | +-----------------+-------+----------+---------------------------------------------------+ 2 rows in set (1.53 sec)

MySQL のログと同様のエラーメッセージが表示されている。repair コマンドを実行しよう。

mysql> repair table foobar; +----------------+--------+----------+--------------------------------------+ | Table | Op | Msg_type | Msg_text | +----------------+--------+----------+--------------------------------------+ | example.foobar | repair | Error | Table 'example.foobar' doesn't exist | | example.foobar | repair | status | Operation failed | +--- ------------+--------+----------+--------------------------------------+ 2 rows in set (0.00 sec)

repair コマンドを実行したら再度 check table コマンドで確認してみよう。

mysql> check table foobars quick; +-----------------+-------+----------+----------+ | Table | Op | Msg_type | Msg_text | +-----------------+-------+----------+----------+ | example.foobars | check | status | OK | +-----------------+-------+----------+----------+ 1 row in set (0.17 sec)

mysql> exit;

テーブルは直ったようだ。Web サイトも確認してみよう。少なくとも、自分の場合はこれで直ったので、ココにメモしておこう。

Sponsored Link

コメント

タイトルとURLをコピーしました