遇到报错:
Error: Table ‘p’ is marked as crashed and should be repaired
Caused by: java.sql.SQLException: Table ‘表名’ is marked as crashed and should be repaired
1.表损坏的原因分析
以下原因是导致mysql 表毁坏的常见原因:
1、 服务器突然断电导致数据文件损坏。
2、 强制关机,没有先关闭mysql 服务。
3、 mysqld 进程在写表时被杀掉。
4、 使用myisamchk 的同时,mysqld 也在操作表。
5、 磁盘故障。
6、 服务器死机。
7、 mysql 本身的bug 。
2.表损坏的症状
一个损坏的表的典型症状如下:
1 、当在从表中选择数据之时,你得到如下错误:
Incorrect key file for table: ‘…’. Try to repair it
2 、查询不能在表中找到行或返回不完全的数据。
3 、Error: Table ‘p’ is marked as crashed and should be repaired 。
4 、打开表失败: Can’t open file: ‘×××.MYI’ (errno: 145) 。
3,解决方案:
第一种修复方式
windows服务器下mysql的修复方法:
F:\sqldata\mysql\bin>cd .. 返回上级目录
F:\sqldata\mysql>cd data 进入数据库