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

后端 未结 14 915
忘掉有多难
忘掉有多难 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 15:00

    On Fedora with systemd MySQL gets private /tmp directory. In /proc/PID_of_MySQL/mountinfo you will find the line like:

    156 129 8:1 /tmp/systemd-namespace-AN7vo9/private /tmp rw,relatime - ext4 /dev/sda1 rw,seclabel,data=ordered

    This means a temporary folder /tmp/systemd-namespace-AN7vo9/private is mounted as /tmp in private namespace of MySQL process. Unfortunately this folder is deleted by tmpwatch if not used frequently.

    I modified /etc/cron.daily/tmpwatch and inserted the exclude pattern -X '/tmp/systemd-namespace*' like this:

    /usr/sbin/tmpwatch "$flags" -x /tmp/.X11-unix -x /tmp/.XIM-unix \
            -x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix \
            -X '/tmp/systemd-namespace*' \
            -X '/tmp/hsperfdata_*' 10d /tmp
    

    The side effect is that unused private namespace folders will not be deleted automatically.

    0 讨论(0)
  • 2020-12-02 15:07

    On debian 7.5 I got the same error. I realized the /tmp folder owner and permissions were off. As another answer suggested I did as follows (must be root):

    chown root:root /tmp && chmod 1777 /tmp
    

    I did not even have to restart mysql daemon.

    0 讨论(0)
提交回复
热议问题