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.

Economic Rubber-Neckers

Paths Traveled

Religious Wars and New Years Resolutions

How To Make Your Site Web 2.0 Compliant

Relativity

Development Software I Can’t Live Without

Making MySQL Worse Than It Already Is

My Phone Rules

Using My Phone as a Wireless Router