Wednesday, May 13, 2015

MySQL Service Control in Windows

Maintaining MySQL on Windows is easier when compared to that of in Linux. Windows offers an advantage to install it as a Windows Service which can be controlled easily with a click.

Starting or stopping of MySQL service on Windows can be done through Windows Service Manager. To do that, open Run and type services.msc which opens the WIndows Service Manager. In that search for MySQL and right click on it. Then you can do whatever operation you want to do. But this can be done only if you have administrative privileges.

There is a facility to start or stop MySQL on Windows even if you are not an administrator. This cannot be done through GUI and should be done through command line. Follow the following steps to control the MySQL Service without non-administrative privileges,

1) To stop the MySQL Service from the command line, open the command prompt and then go the base directory or the installation directory of the MySQL, generally

C:\Program Files\MySQL\MySQL Server 5.6\bin

2) Now run the following command to stop the MySQL Server,

mysqladmin -u root shudown

    If you have a password to the 'root' account then the command will be,

mysqladmin -u root -p<password> shutdown

3) To start the service again, the general suggested command that should be run in the same installation directory is as follows,

mysqld

But this doesn't work if the server's configuration file is present in a location other than the installation directory. In such case, the above command should be appended with the location of the configuration file, as follows,

mysqld --defaults-file="<Location of the file>"

If you have MySQL Workbench installed, it provides an option to start or stop the server in its INSTANCE section of Management. It issues the above shell commands automatically when clicked either on "Stop Server" or "Start Server" button.

No comments:

Post a Comment