Bookmark and Share
How to repair a crashed MyISAM table?
(Publish Date: 2009-10-26 10:52pm, Total Visits: 3197, Today: 2, This Week: 3, This Month: 4)

A MyISAM table got the following error message in the mysql error log:

091026 21:00:01 [ERROR] /usr/sbin/mysqld: Incorrect key file for table './openadstest/phpads_data_raw_ad_click.MYI'; try to repair it
091026 21:00:01 [ERROR] /usr/sbin/mysqld: Incorrect key file for table './openadstest/phpads_data_raw_ad_click.MYI'; try to repair it

We can use "check" to analyze and use "repair" to repair the table

mysql> check table phpads_data_raw_ad_click;
+--------------------------------------+-------+----------+----------------------------------------------------------+
| Table                                | Op    | Msg_type | Msg_text                                                 |
+--------------------------------------+-------+----------+----------------------------------------------------------+
| openadstest.phpads_data_raw_ad_click | check | warning  | Table is marked as crashed                               |
| openadstest.phpads_data_raw_ad_click | check | warning  | 6 clients are using or haven't closed the table properly |
| openadstest.phpads_data_raw_ad_click | check | warning  | Size of datafile is: 97476608       Should be: 97473808  |
| openadstest.phpads_data_raw_ad_click | check | error    | Found 528046 keys of 514988                              |
| openadstest.phpads_data_raw_ad_click | check | error    | Corrupt                                                  |
+--------------------------------------+-------+----------+----------------------------------------------------------+
5 rows in set (11.20 sec)

mysql> repair table phpads_data_raw_ad_click;
+--------------------------------------+--------+----------+-------------------------------------------------+
| Table                                | Op     | Msg_type | Msg_text                                        |
+--------------------------------------+--------+----------+-------------------------------------------------+
| openadstest.phpads_data_raw_ad_click | repair | info     | Wrong bytesec:   0-  0-  0 at 97473808; Skipped |
| openadstest.phpads_data_raw_ad_click | repair | status   | OK                                              |
+--------------------------------------+--------+----------+-------------------------------------------------+
2 rows in set (20.81 sec)

mysql> check table phpads_data_raw_ad_click;
+--------------------------------------+-------+----------+----------+
| Table                                | Op    | Msg_type | Msg_text |
+--------------------------------------+-------+----------+----------+
| openadstest.phpads_data_raw_ad_click | check | status   | OK       |
+--------------------------------------+-------+----------+----------+


[Total Users: 1]

I want to comment on it

Display: 1 - 0 of 1, Total Pages: 0