Thursday, May 9, 2013

MySQL ERROR 1 (HY000): Can't create/write to file

> desc foo_table;
ERROR 1 (HY000): Can't create/write to file '/tmp/#sql_3ff6_0.MYI' (Errcode: 13 - Permission denied)

Now this error is documented :

This is a straight forward fix.  What happened to the permissions on the /tmp folder ? Because it is not allowing writes.  So first have to fix that then start looking into what or who changed permissions on the directory.

chmod 1777 /tmp

I will use this error as an example, even though it is pretty straight forward to see and then fix.

First look at the entire error message and do not focus on the first error you see.
For example if you have an Errcode:

  • do not focus on ERROR 1
  • do not focus on HY000

You would be wasting your time when the Errcode gives you all the information you need.
If that happened to be the only error message information that was passed to you then you do have resources available to look up errors :

I would also stress that you should double check the error log to confirm all error messages.
Just because someone sends you an error does not mean it is the entire story, always check your logs.

If you do run across an error that gives you little description it is true that you have the ability to learn more about the error.

"describing the last error encountered during a call to a system or library function." --

# perror 13
OS error code  13:  Permission denied

BTW.. related to the error above,  it is also possible to change your tmpdir location if that was required. In this case it was not but it you ever need to change or override the defaults you can find your current tmpdir with this:
> select @@tmpdir;
| @@tmpdir |
| /tmp     |
You can edit the my.cnf and place tmpdir=/tmp whatever location you prefer.