MySQL: Can't create/write to file '/tmp/#sql_3c6_0.MYI' (Errcode: 2) - What does it even mean?

后端 未结 14 995
忘掉有多难
忘掉有多难 2020-12-02 14:00

For some reason my production DB decided to spew out this message. All application calls fail to the DB with the error:

PreparedStatementCallback; SQL [ /*lo         


        
14条回答
  •  误落风尘
    2020-12-02 14:49

    I'm using mariadb. When I try to put this line at /etc/my.cnf:

    [mysqld]
    tmpdir=/tmp 
    

    It solved the error generated from website frontend related to /tmp. But, it has backend problem with /tmp. Example, when I try to rebuild mariadb from the backend, it couldn't read the /tmp dir, and then generated the similar error.

    mysqldump: Couldn't execute 'show fields from `wp_autoupdate`': Can't create/write to file '/tmp/#sql_1680_0.MAI' (Errcode: 2 "No such file or directory") (1)
    

    So this one work for both front end and back end:

    1. mkdir /var/lib/mysql/tmp

    2. chown mysql:mysql /var/lib/mysql/tmp

    3. Add the following line into the [mysqld] section:

        tmpdir = /var/lib/mysql/tmp
    

    4. Restart mysqld (eg. Centos7: systemctl restart mysqld)

提交回复
热议问题