MySQL Error Code 17?

Posted By : todd sharp Posted At : May 21, 2008 3:40 PM Posted In: SQL

6

I don't usually like to post asking for help, but over the last few weeks I've seen some variation of the following error on my server:

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

The file name is usually different, but the Errcode (17) is always the same. A quick google search shows that MySQL error code 17 means that the file exists (so it can't be overwritten), but nothing I've found tells me a.) what the heck the file is or b.) why it already exists or c.) how to make sure it doesn't exist the next time the process tries to write to it.

Any MySQL gurus out there have an idea? If I do the good old 'reboot' the problem goes away (for a few days/hours anyways).

Comments (6)

todd sharp's Gravatar As a side note, it seems to affect only certain SELECT queries - and there is no rhyme or reason to the tables/databases that it affects. For example my blog is obviously functioning, but trying to display posts by category (http://cfsilence.com/blog/client/index.cfm?mode=ca... - or my RSS feed) will throw the error.

Scott Bennett's Gravatar a) You need to clear out your servers temp folder. If it doesn't get cleared out on a regular basis sometimes these files get left there and eventually MySQL will try to use that file name again but the file already exists and throws this error.
-or-
b) In older versions of MySQL this can be caused by the antivirus software on your server locking the files.

Scott Bennett's Gravatar If it's problem and it continues to happen you might want to schedule a batch process to clear the folder out on a regular basis.

Scott Bennett's Gravatar Also, sorry to bombard you with comments, but as a disclaimer, I am not a "MySQL Guru" per se, but I have experienced this problem before and clearing out the temp folder worked for me.

I'm not sure about if writing a batch process will help or not because I'm not sure exaclty why or how often MySQL tries to create these files with the same name. so trying to schedule something may not be practicle. I only that some "unknown to me" circumstance causes it to try to create these .MYD files that already exists and you have to delete the file from the temp folder to get it to work again.

Oğuz Demirkapı's Gravatar This is because of the rights problem on the temp directory.

This would be NTFS permissions or any AntiVirus software etc.

I would suggest to create a tmp directory under the MySQL directory and define this directory in my.ini for the parameter tmpdir.

If you have any AntiVirus software please try to add MySQL directory into exclude list.

Gerald's Gravatar Repair the table.