Home  >  Article  >  Database  >  MySQL临时表过大报错

MySQL临时表过大报错

WBOY
WBOYOriginal
2016-06-07 16:59:161237browse

mysql 报如下的错误:ERROR 126 (HY000): Incorrect key file for table

mysql 报如下的错误:

ERROR 126 (HY000): Incorrect key file for table '/tmp/#sql_6613_0.MYI'; try to repair it

发现其原因是临时表太大了,而/tmp分区只有2G,放不下就报错了。
如果把中间结果自己建一个临时表

create temporary table tmp select ...

建出的表文件只有100M左右,那么为什么/tmp中会放不下呢?
猜测MySQL自己建的临时表都是静态行(没有找到资料证实)。有这样的猜测是因为如果用

create temporary table tmp row_format=fixed select ...

建表就会出现同样的错误了。

所以这个问题有两个解决方法:
1. 自己建临时表,需要修改代码,,费时。
2. 加大临时目录。
1.1 可以加大/tmp分区,
1.2 可以在启动MySQL时设置TMPDIR环境变量指定另外的临时目录

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn