When you start the MySQL80 service, it immediately stops and gives the following error:
“The MySQL80 service on Local Computer started and then stopped. Some services stop automatically if they are not in use by other services or programs.”
The solution I came across was ridiculously simple but took me a while to find, so I thought I would make another resource online to hopefully save you some time and trouble. I found a lot of sites that mentioned installing MySQL as a service using mysqld –install and then running mysqld –initialize , but I wouldn’t start there.
Somehow the my.ini config file can get HEX characters added to the beginning of the file. At least on Windows servers, this causes the MySQL service to fail when it tries to start. The solution is to remove these HEX characters and then start the service again.
Since HEX characters aren’t visible if you’re using a regular text editor, like the built-in Notepad, you’ll have to install another program.
The solution I found was mentioned at https://docs.rackspace.com/support/how-to/how-to-resolve-mysql-service-starting-and-stopping-unexpectedly/
Steps to Fix MySQL80 Service
When you open your my.ini config file (on Windows, found in C:\ProgramData\MySQL\MySQL Server 8.0 –> you might have a different server version number), you don’t immediately notice the HEX characters unless you view it with a HEX viewer.
One of the simplest ways to get a HEX view of your my.ini file is to use Notepad++ and run the “HEX-Editor” plugin. If you’re not already using Notepad++ for all your text editor needs…you should be. Download Notepad++ here.
Once you’re running Notepad++, you can add the HEX-Editor plugin. In Notepad++, click Plugins -> Plugins Admin… -> search for “HEX”. You’ll see “HEX-Editor” as one of the plugins you can install. Select it and click Install.
Notepad++ should close, install the plugin, then restart. Once you have it open again, open your my.ini config file in Notepad++, click Plugins -> HEX-Editor -> View in HEX.
Remove the HEX Characters
When I viewed my.ini in HEX view, I had 3 HEX characters before the initial “#” symbol that I saw when I viewed my.ini in a regular text editor like Notepad (or Notepad++ without HEX view turned on).
Select any leading HEX characters and press “Delete” on your keyboard. I don’t remember specifically, but you may also be able to right-click on your selection and click Delete. Either way, make those HEX characters disappear and then save your file. The config file should start with the “#” symbol.
Have a Party
Now that you’ve removed the HEX characters and saved your my.ini config file again, you should be able to start the MySQL80 service again. Then you should celebrate and have a cup of coffee.
Note: This may also apply to other versions of MySQL, but the one I specifically encountered this with was MySQL version 8.0.26.
Leave a Comment
I hope this helps you. I thanked God when I came across this fix! It saved me a day of reinstalling and restoring data 🙂
Reach out to me directly or leave a comment below if you need any help or have any questions.