一臺mysql 伺服器,機器意外重啟後,N個表報錯,想必你已經知道庫的引擎是myisam 的了,太悲催,太蛋碎了,先看看報錯資訊:

mysql> desc PARTITION_KEYS;
ERROR 130 (HY000): Incorrect file format `PARTITION_KEYS`
mysql> check table PARTITION_KEYS;
+-------------------------+-------+----------+----------------------------------------+
| Table                   | Op    | Msg_type | Msg_text                               |
+-------------------------+-------+----------+----------------------------------------+
| hivedbwm.PARTITION_KEYS | check | Error    | Incorrect file format `PARTITION_KEYS` |
| hivedbwm.PARTITION_KEYS | check | error    | Corrupt                                |
+-------------------------+-------+----------+----------------------------------------+
2 rows in set (0.00 sec)

執行REPAIR TABLE table_name USE_FRM; 修復:

mysql> REPAIR TABLE PARTITION_KEYS USE_FRM;
+-------------------------+--------+----------+----------+
| Table                   | Op     | Msg_type | Msg_text |
+-------------------------+--------+----------+----------+
| hivedbwm.PARTITION_KEYS | repair | status   | OK       |
+-------------------------+--------+----------+----------+
1 row in set (0.02 sec)

mysql> desc PARTITION_KEYS;                
+--------------+---------------+------+-----+---------+-------+
| Field        | Type          | Null | Key | Default | Extra |
+--------------+---------------+------+-----+---------+-------+
| TBL_ID       | bigint(20)    | NO   | PRI | NULL    |       |
| PKEY_COMMENT | varchar(4000) | YES  |     | NULL    |       |
| PKEY_NAME    | varchar(128)  | NO   | PRI | NULL    |       |
| PKEY_TYPE    | varchar(767)  | NO   |     | NULL    |       |
| INTEGER_IDX  | int(11)       | NO   |     | NULL    |       |
+--------------+---------------+------+-----+---------+-------+
5 rows in set (0.02 sec)