MySQL表损坏修复【Incorrect key file for table】

今天机房mysql服务器异常关机,重新启动后报错如下:

2017-09-08 09:35:20 1808 [ERROR] /usr/local/mysql/bin/mysqld: Incorrect key file for table './cdb/passport_account.MYI'; try to repair it
2017-09-08 09:35:20 1808 [ERROR] /usr/local/mysql/bin/mysqld: Incorrect key file for table './cdb/passport_account.MYI'; try to repair it
2017-09-08 09:35:20 1808 [ERROR] Got an error from thread_id=115353, /usr/local/src/mysql-5.x.30/storage/myisam/mi_update.c:223
2017-09-08 09:35:20 1808 [ERROR] MySQL thread id 115353, OS thread handle 0x7ff560e3d700, query id 40381677 192.168.5.202 csr updating

修复方法如下:

mysql> repair table passport_account;
+----------------------+--------+----------+----------+
| Table                | Op     | Msg_type | Msg_text |
+----------------------+--------+----------+----------+
| cdb.passport_account | repair | status   | OK       |
+----------------------+--------+----------+----------+
1 row in set (3 min 34.72 sec)

恢复正常。

ps:有朋友遇到到执行SQL的时候,产生临时数据占满了/tmp磁盘空间,可以把临时文件选择放在空间大的磁盘目录下面,解决方法如下:

mysql> show variables like 'tmpdir';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| tmpdir        | /tmp  |
+---------------+-------+
1 row in set (0.00 sec)

mysql> set global tmpdir = '/Data/xxx/mysqltmp';
ERROR 1238 (HY000): Variable 'tmpdir' is a read only variable

如果有报错可以配置文件

vim /etc/mysql/my.cnf

此处可以修改 tmpdir 的属性值,也可以修改 query_cache_limit 的数值,建议使用后者

重启MySQL就ok了

 

转载于:https://www.cnblogs.com/xiewenming/p/7493184.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值