分类: MySQL

MySQL: Incorrect key file for table '/tmp/#sql_37b_1.MYI'; try to repair it 解决方法

Incorrect key file for table '/tmp/#sql_37b_1.MYI'; try to repair it

执行存储过程的时候报这个错误,df看了下空间/tmp分区只有2G空间,

[root@mallerppredb01 ~]# df -h
Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/systemvg-rootlv   10G  198M  9.8G   2% /
devtmpfs                      16G     0   16G   0% /dev
tmpfs                         16G   12K   16G   1% /dev/shm
tmpfs                         16G   57M   16G   1% /run
tmpfs                         16G     0   16G   0% /sys/fs/cgroup
/dev/mapper/systemvg-usrlv    10G  2.6G  7.5G  26% /usr
/dev/vda1                    497M  131M  367M  27% /boot
/dev/mapper/systemvg-optlv    33G  4.3G   29G  14% /opt
/dev/mapper/systemvg-varlv   8.0G  569M  7.5G   7% /var
/dev/mapper/systemvg-homelv   20G   48M   20G   1% /home
/dev/mapper/systemvg-tmplv   2.0G   45M  2.0G   3% /tmp
/dev/mapper/systemvg-datalv  580G   11G  570G   2% /data
tmpfs                        3.2G     0  3.2G   0% /run/user/0

查看mysql的tmpdir参数:

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

tmpdir参数不支持热设置,只能增加/tmp目录空间或通过配置文件进行修改

在my.cnf里面的[mysqld]部分增加
tmpdir=/data/mysqltmp
然后重启mysql服务,/data/mysqltmp这个目录,mysql用户、组要有读写权限。
tmpdir参数文档:https://dev.mysql.com/doc/refman/5.7/en/server-options.html#option_mysqld_tmpdir

此处评论已关闭