场景说明: 这个MySQL表损坏的场景是发生在2018年线上库的某个月 当时MySQL的版本是MySQL5.6。 硬件:服务器的硬件配置是PowerEdge R320 Intel(R) Xeon(R) CPU E5-2403 v2 @ 1.80GHz * 4 4核心 8G内存,机械硬盘

dr_stats表 由于服务器意外宕机这个表损坏了。 此时正好这个dr_stats表的引擎为myIsam。 这个表里面是13362万记录数,这个表是myIsam的数据存储引擎,所以即使是表损坏了,mysql的服务还是可以正常启动和登录mysql服务的,但是此时这个dr_stats表已经不能写入数据了 在线修复这个表MyIsam的引擎的表 check table dr_stats 执行了24分钟,repair table dr_stats 执行了30分钟

mysql> use drsj;
Database changed
mysql> check table dr_stats;
+---------------+-------+----------+---------------------------------------------------------+
| Table         | Op    | Msg_type | Msg_text                                                |
+---------------+-------+----------+---------------------------------------------------------+
| drsj.dr_stats | check | warning  | Table is marked as crashed                              |
| drsj.dr_stats | check | warning  | 1 client is using or hasn't closed the table properly   |
| drsj.dr_stats | check | error    | Checksum for key:  3 doesn't match checksum for records |
| drsj.dr_stats | check | error    | Corrupt                                                 |
+---------------+-------+----------+---------------------------------------------------------+
4 rows in set (24 min 57.36 sec)

mysql> 
mysql> 
mysql> repair table dr_stats;
+---------------+--------+----------+----------+
| Table         | Op     | Msg_type | Msg_text |
+---------------+--------+----------+----------+
| drsj.dr_stats | repair | status   | OK       |
+---------------+--------+----------+----------+
1 row in set (30 min 6.36 sec)

mysql> 

到此时,这个表完成了修复,可以正常写入数据了。