How to Install/Uninstall/Execute MySQL as Windows Service

On Windows, It is always recommended to install and run MySQL as a Windows service, so that MySQL starts and stops automatically when Windows starts and shutdown. Also, it can be managed using the services section of control panel. A MySQL installed as a service can also be controlled from the command line using NET commands (command to start a service), or with the graphical Services utility. Generally, to install MySQL as a Windows service you should be logged in using an account that has administrator rights.

MySQL

This post is in continuation to series about learning MySQL concepts. In previous post, we learned about MySQL Configuration and Command Line Options. In this post, I will talk about installing and using MySQL as a windows service.

Install MySQL as windows service

To install MySQL as a Windows service manually, execute this in a command line shell, e.g.

prompt> mysqld --install MySQLXY --defaults-file="C:Program FilesMySQLMySQL Server 5.1my.ini"

Where “MySQLXY” is any service name you want to give to MySQL windows service. And “defaults-file” is the location of configuration file which you want to use for providing startup configuration parameters.

Start MySQL as windows service

To Start the installed windows service from command prompt, execute this command e.g.

prompt> net start MySQLXY

Above command will start the service and as a result, MySQL will be running into your system.

Install as a MySQL Windows service manually
Install as a MySQL Windows service manually

Remove/Uninstall MySQL as windows service

To uninstall the installed windows service from command prompt, execute this command e.g.

prompt> sc delete MySQLXY

Above command will delete the windows service. It will not uninstall the MySQL from your system, only windows service gets deleted. NO HARM !!


Need to be done from a command prompt with administrator privileges.

Happy Learning !!

8 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments

Comments are closed for this article!

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.