mysql:テーブルのrepair
mysqlでこんなエラーメッセージが出てた。
Table table_name is marked as crashed and should be repaired
とりあえず、エラーが出ているテーブルを調べる。
mysql> check table table_name;
+----+---+----+-------------------+
| Table | Op | Msg_type | Msg_text |
+----+---+----+-------------------+
| table_name | check | warning | Table is marked as crashed |
| table_name | check | warning | 1 client is using or hasn’t closed the table properly |
| table_name | check | error | Record at pos: 482160 is not remove-marked |
| table_name | check | error | record delete-link-chain corrupted |
| table_name | check | error | Corrupt |
+----+---+----+-------------------+
+----+---+----+-------------------+
| Table | Op | Msg_type | Msg_text |
+----+---+----+-------------------+
| table_name | check | warning | Table is marked as crashed |
| table_name | check | warning | 1 client is using or hasn’t closed the table properly |
| table_name | check | error | Record at pos: 482160 is not remove-marked |
| table_name | check | error | record delete-link-chain corrupted |
| table_name | check | error | Corrupt |
+----+---+----+-------------------+
確かにテーブルにエラーがある。
これを直すにはrepairコマンドを使うらしい。
mysql> repair table table_name;
+----+----+----+--------------+
| Table | Op | Msg_type | Msg_text |
+----+----+----+--------------+
| table_name | repair | warning | Number of rows changed from 63 to 64 |
| table_name | repair | status | OK |
+----+----+----+--------------+
これで直ったっぽい。+----+----+----+--------------+
| Table | Op | Msg_type | Msg_text |
+----+----+----+--------------+
| table_name | repair | warning | Number of rows changed from 63 to 64 |
| table_name | repair | status | OK |
+----+----+----+--------------+
どうしてこの手順で直るのかはいつか調べる。