Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can't create/write to file '#sql_1fc7_3.MYD' (Errcode: 17)

how can i fix that?

share|improve this question
up vote 1 down vote accepted

Error 17 is "file exists".

See if anything else has #sql_1fc7_3.MYD open:

lsof | grep '#sql_1fc7_3.MYD'

If it doesn't, then move it. I'm not sure what led to this problem, but one guess is that MySQL crashed at some point and as a result didn't clean up a temp table's file named #sql_1fc7_3.MYD.

share|improve this answer
mhh... that would make sense. had a mysql crash twice. when you mean move it, just move the file or change something in the conf? – daniel Mar 25 '10 at 11:29
I mean move the file somewhere else, like 'mv /tmp/#sql_1fc7_3.MYD ~' (assuming MySQL's tmpdir is /tmp). Really, if it's not in use, there's no reason not to delete it, but I don't want to mislead you if I'm wrong. – jlupolt Mar 25 '10 at 12:53
moving the file worked. hope this is a permanent fix – daniel Mar 30 '10 at 13:35

Python 2.6 (r26:66714, Nov  3 2009, 17:33:38) 
[GCC 4.4.1 20090725 (Red Hat 4.4.1-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import errno
>>> errno.errorcode[17]

Are you trying to create a table post-restore or something like that? What commands are you trying to execute that cause that error?

share|improve this answer

A few possibilities:

1) the file already exists from a previously attempted repair/alter table that failed or is still in progress (show processlist)

2) your system is set to write temporary tables to /tmp which is not chmod 1777 (or /var/tmp)

3) your mysql database directory is not owned by the process that is running mysql (or mysqld doesn't have privileges to write to that database directory.

share|improve this answer

I have seen this error several times. I'm not sure how this happens, but in my case it's caused by the /tmp/ directory on the database server suddenly becoming only writable by the root user (as suggested by the previous answerer). I have no clue why this keeps happening, but I set it back via "chmod 777 /tmp/" and the error immediately goes away.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.