9

How To Fix Intermittent MySQL Errcode 13 Errors On Windows


Posted by Artem Russakovskii on January 5th, 2010 in Databases, MySQL, PHP, Programming
Share

9 Responses to “How To Fix Intermittent MySQL Errcode 13 Errors On Windows”

    9 Comments:
  1. ColdMan says:

    I wonder if this problem happens with all antiviruses or just some. In other words can the bad ones do something to fix it or it won't be possible without mysql's own changes…

    • I am not sure, but my guess is it happens with the ones that lock the file until it's been checked, to avoid spreading the infection in case it IS a virus. Hopefully, most of that actually do that.

      • Vladislav Vaintroub says:

        Well, in the described case MySQL is trying to delete the file, and I would expect AV to be smart enough and not block opening for deletion – a removed file can impossibly spread the virus:)

        • Vladislav, I don't know enough about Windows internals to be able to tell if there's a way to do a file lock without locking it from being deleted. Maybe you could tell us (and Microsoft, and McAfee :-] )

          • Vladislav Vaintroub says:

            Windows has something called file sharing mode, which is documented in CreateFile. When opening a file, one specifies desired access (read,write, delete and there is a bunch of others like "read attributes") and file sharing mode (combination of FILE_SHARE_READ,FILE_SHARE_WRITE or FILE_SHARE_DELETE). when file is removed it is opened with desired access="read attributes + delete", sharing mode =read,write,delete sets DELETE_ON_CLOSE flag and closes the file.

            So, if AV would open the file with FILE_SHARE_DELETE it would be possible to delete it even if AV still has it opened, though the file would not completely disappear from the file system until the last handle to it is closed, i.e until AV closes the file.

            I think Microsft would know this already :)

          • Thanks for the details, Vlad. Perhaps someone from MS will see this and raise as an issue.

  2. Lachlan Mulcahy says:

    @ColdMan: It is generally recommended process to set all AV to skip over MySQL database files. If they aren't causing problems with locking like this then they can cause issues with performance.

    I'd suggest skipping scanning of your entire datadir and all *.frm, *.MYI, *.MYD and *.ibd files in your MySQL temp dir.

    If your server is dedicated to MySQL use, then the risk of introducing a virus to the system is greatly reduced anyhow.

  3. S says:

    Artem,

    You don't need an AV. Create a limited guest account for all your work sans sysadmin tasks, and use your Administrator account for the latter. If you really need Administrator rights, you can "Run as Administrator" (right-click). Use cygwin for file permissions.

    Xampp is *way* better than Wampserver. I could not use xdebug with the latter.

    S

  4. Chris webb says:

    Thanks for sharing this really useful article; I have had a similar problem in the last few weeks.

Leave a Reply

Connect with Facebook