MySQL: Cannot create Windows service for MySQL. Error: 0

I’ve beaten my skull bloody trying to fix this one…the MySQL forums weren’t much help.  There are lots of red herrings out there, so I’m posting this in the hope that Google will find it and put it on the first page and that others will subsequently be helped.

The dreaded MySQL "Error: 0"

The dreaded MySQL "Error: 0"

The forums won’t help you much.  Here’s what you need to do:

  1. Click the “Cancel” button and get out of the Service Configurator.
  2. Use the MySQL.msi that you used to install to unintall MySQL.  Side note: keep the MSI around.  It does a better job of removing MySQL than the Windows Control Panel Add/Remove does.
  3. Go to this path: C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server <version>\data
  4. Delete EVERYTHING in that directory.
  5. Go to this path: C:\Program Files\MySQL\MySQL Server <version>
  6. Delete EVERYTHING in this directory.
  7. Just to be sure, open up a command prompt and type “sc delete MySQL” (or whatver you were trying to call your service.  I usually name the services after the version, so in my case it is “sc delete MySQL5131″
  8. Reinstall MySQL.
  9. Try to configure the service again.  It should work.

You might get the “Cannot create Windows service for MySQL. Error: 0″ again.  If you do:

  1. Cancel out of the configurator.
  2. Fire up the MySQL installer MSI again.  This time, choose the “Repair” option and let it do it’s thing.
  3. Retry the configurator, but this time you’ll notice that it asks you for the “Current password”.
  4. Try the password you entered last time.  It might work, or you might get this screen:

    Password problems

    Password problems...YAY!

  5. Try again, but this time don’t put ANYTHING for the current password…just leave it blank.
  6. You should see this lovely screen…finally:

    Success...finally!

    Success...finally!

The root of this problem is that MySQL does a crappy job of cleaning out the data directory on an uninstall and it leaves instance information behind.  Then when you try to re-install, it coughs up a lung and hangs partway through the install, leaving everything half baked.

6 Comments so far »

  1. parenghilton said,

    Wrote on April 18, 2009 @ 12:55 am

    thanks you saved my day…

  2. lk said,

    Wrote on June 19, 2009 @ 1:51 am

    Finally!
    Though it didn’t seem to work with MySQL 5.1, only with v5.0

    Thanks for ending my hours of frustration!

  3. bhavani said,

    Wrote on August 1, 2009 @ 10:24 am

    Thanks a million !!!!!

  4. tiantiandandan said,

    Wrote on October 25, 2009 @ 10:58 pm

    You solved my trouble…. Thank you so much!!! Hug!!! Brother!!

  5. joserey said,

    Wrote on November 19, 2009 @ 7:51 am

    Way to go! All it takes is a really good clean-up. In my case, the problem stemmed from a previously installed mysql lurking somewhere in c: that left some remnants of its instance. I am now running apache with it’s own mysql and iis with it’s own mysql, both in one machine!

  6. zena_the_warrior_princess said,

    Wrote on January 13, 2010 @ 9:47 pm

    You are the man!!!!!
    You are the only one who could help me. After hours of trying all the numerous advices from forums…yours worked. I actually used Add/remove Program (couldn’t figure out how to use .msi I’m a newbie :). I also used the mirror from Europe that time (don’t think it make a difference though).
    I’m hoping I can bug you with questions in the future.
    Thanks
    Z

Comment RSS · TrackBack URI

Leave a Comment

You must be logged in to post a comment.