The strangest thing happened to a MySQL server (running Windows Server 2003) I set up today. MySQL would install with no problem, work all day with no problem, then fail after a reboot.

The MySQL service simply wouldn’t start, producing this error message:

Could not start the MySQL service on Local Computer.
Error 1067: The process terminated unexpectedly.

First I checked the my.ini file and saw no obvious problems (it was also the default my.ini file produced by the installer). Since the service wouldn’t start, I created a new one that made sure it was reading the right .ini file:

$ mysqld --install MySql2 --defaults-file="c:my.ini"

… but to no avail, as the same error occurred. Eventually I gave up and reinstalled MySQL. But it still didn’t work!

I did learn two interesting things:

  • When trying to delete a service from Windows, make sure that the Services Manager is not open. The deleted service only gets truly deleted when the Services Manager is closed, which may leave you wondering why it’s taking so long (“This service is marked for deletion”).
  • When you need to reinstall MySQL, in order to really start fresh, you need to do three things:
    • Uninstall MySQL (Add/remove programs, etc.)
    • Delete the MySQL program directory
    • Delete the MySQL data directory (under Documents and Settings, Application Data, etc.)

When I did a truly “fresh” install of MySQL, it actually worked again. But only till the next reboot. I found out when there was a power outage later during the day. MySQL wouldn’t start, and manually starting the service would produce, again, the error 1067.

This time I had a look at the MySQL log file, which lives in the data directory (called server001.err in my case). I found this:

120420  8:21:38  InnoDB: Operating system error number 87 in a file operation.
InnoDB: Some operating system error numbers are described at
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/operating-system-error-codes.html
InnoDB: File name .ib_logfile0
InnoDB: File operation call: 'aio read'.
InnoDB: Cannot continue operation.

Ah, more information on the error. It turns out that Windows error 87 is ERROR_INVALID_PARAMETER; in other words: “The parameter is incorrect” (see here). Not particularly helpful, but it gets you something to Google for.

There weren’t too many Google results, but after I while I found this. It seems that the error is related to either the disk driver or the formatting of the disk (neither of which I could easily change on a remote server). But the bug report did include a workaround. Add this to my.ini:

innodb_flush_method=normal

And it works!