MySQL – Can’t Create/Write to File ‘/tmp/#sql_xxxx.MYI’ (Errcode: 13)

debianMySQL

I have installed Debian Lenny, PHPmyadmin and postfix.

When using PHPmyadmin GUI and access any table with data i get:

Can't create/write to file '/tmp/#sql_xxxx.MYI' (Errcode: 13)

doing perror 13 says:

OS error code  13:  Permission denied

I find the tmpdir lik so:

mysqladmin -p variables | grep -w tmpdir
| tmpdir                          | /tmp

Now that means that mysql cannot write to /tmp. Making the permissions to :777 fixes that. But I doesn't feel right I have to do that. Is there a better way/fix?

Should I change the value tmpdir in /etc/mysql/my.cnf?

Best Answer

It looks like your permissions on /tmp are wrong. They really should be read/write/execute for everyone with the sticky bit set.

chmod 1777 /tmp

The sticky bit add some restrictions to how other users interact with files not created or owned by them, so there's no reason to worry.

If you wish, you may also create a seperate directory owned and writeable by the mysql user and specify that directory in my.cnf to be used instead of the system wide /tmp.