Pages

Thursday 16 February 2012

Fixing MySQL Error 1067 on Windows Server 2008 r2

Let me just start by saying that this has been really annoying me for some time now and obviously taking the server offline to fix this is difficult at the best of times.  Fortunately, this week I've had the time to take a look at this and see if I can sort the issue.

From looking at all of the various 'solutions' out there, it doesn't actually seem that any of them are correct.  Don't get me wrong, I'm sure there is one somewhere but I didn't manage to find it past page two of Google so I thought I would give it a go myself.  Just to save you some time, the following doesn't work despite what a lot of people will have you believe (and if they do, then you have been lucky):
  • Removing the service and reinstalling;
  • Removing and recreating the log files;
  • Repairing the install;
  • Recreating your MySQL instance;
Now the reason that it happened on my server was due to an upgrade from MySQL 5.1.x to 5.5.x a few months ago.  I thought that I had done the usual routine correctly of taking backups, downing the service, uninstalling, reinstalling and then restoring.  Job done I thought.  This has never been a problem on any other server that I've done this and so I wasn't expecting this.  All it meant was that from time to time, the service wouldn't start after a Windows reboot.  Not really a big deal but any down time at all is a big no no.

So, in essence you will actually need to do most of your preparation that you would normally do for an upgrade.  You might as well download the latest version of MySQL while you do this so firstly go and grab that.  Next, do your normal backup of your databases and also your my.ini from wherever you normally keep it.  Stop your MySQL service and then uninstall your MySQL installation.  Go to your ProgramData folder and remove your MySQL folder, and do the same in your Program Files\MySQL folder (remove your server folder just in case you have your tools or workbench installed in there).  Now go to your Users folder and have a look through there and it will normally be hidden in your Default\AppData folder.  Launch regedit and search for 'mysql' and remove any instance of it that is related to your server install.  Restart your server now.

When your server comes back on, run your nice new installer, giving it the same settings that you had before.  Set a new instance up (it can be the same service name if you like) and then it will go off and set your my.ini, your service and your security settings.  Your service should now be running straight away.  Just to check it though, stop the service and start it again.  You should find that it's running without erroring.  If it does error, not to worry, open a command prompt and browse to your bin folder inside your new installation and run the following:
mysqld -remove MySQL
Where MySQL is the name of your service that you specified.  Assuming that you have typed that in correctly it will say that it has removed the MySQL service.  Now run the instance configuration wizard again (inside your bin folder) and go through it again.

Lastly, restore your databases and users / permissions and you should be done.  Sorry that this is a bit lengthy but this worked for me and every other solution that I found didn't sort my problem.  It seems that this error goes way, way back to MySQL 4.x but nobody has worked out a way to fix this properly.  As I mentioned before, other people have posted their solutions which may have worked for them, but that could mean that this is an inconsistent error which is why it hasn't been fixed as of yet.