mysql DBダンプ エラー 修復してみた。

この記事を読む およそ時間 < 1

DBダンプを取ってみる!
mysqldump -u root -p –all-database > all.dump

なんですとぉ!!!!
mysqldump: Got error: 145: Table ‘./DBname/dadada_logcounterx_log’ is marked as crashed and should be repaired when using LOCK TABLES

テーブルが壊れていると言っている。

○チェックしてみよう。

mysql -p -u root

mysql> use DBname;

mysql> check table dadada_logcounterx_log medium;

+—————————-+——-+———-+———————————————————–+
| Table | Op | Msg_type | Msg_text |
+—————————-+——-+———-+———————————————————–+
| DBname.dadada_logcounterx_log | check | warning | Table is marked as crashed |
| DBname.dadada_logcounterx_log | check | warning | 4 clients are using or haven’t closed the table properly |
| DBname.dadada_logcounterx_log | check | error | Size of indexfile is: 3423232 Should be: 3424256 |
| DBname.dadada_logcounterx_log | check | error | Size of datafile is: 70559388 Should be: 70559764 |
| DBname.dadada_logcounterx_log | check | error | Corrupt |
+—————————-+——-+———-+———————————————————–+
5 rows in set (0.01 sec)

エラー出まくりやんかぁ!!!
修復してみる!!

mysql> repair table dadada_logcounterx_log USE_FRM;
+—————————-+——–+———-+—————————————–+
| Table | Op | Msg_type | Msg_text |
+—————————-+——–+———-+—————————————–+
| DBname.dadada_logcounterx_log | repair | warning | Number of rows changed from 0 to 333335 |
| DBname.dadada_logcounterx_log | repair | status | OK |
+—————————-+——–+———-+—————————————–+
2 rows in set (3.28 sec)

OK修復された。

再度チェック
mysql> check table dadada_logcounterx_log medium;
+—————————-+——-+———-+———-+
| Table | Op | Msg_type | Msg_text |
+—————————-+——-+———-+———-+
| DBname.dadada_logcounterx_log | check | status | OK |
+—————————-+——-+———-+———-+
1 row in set (1.10 sec)

mysql> quit
Bye

改めてダンプの取り直しを
[root@sns tmp]# mysqldump -u root -p –all-database > all.dump
Enter password:

-rw-r–r– 1 root root 216898191 Oct 1 11:57 all.dump
取得できた。めでたしめでたし・・・。

Related posts