Syntax for Creating a Windows Service for MySQL (when there are 2 paths which both contain spaces)

Numerous times now, I’ve seen people have troubles creating MySQL services on Windows manually (using ‘sc’), whether it be for mysqld itself, MySQL Proxy, or the MySQL Enterprise Monitor and/or Agent.

The proper syntax for ‘sc’ can get tricky when you have spaces in pathnames, which is very common in Windows, and the need for –defaults-file (which means two paths each potentially containing spaces).

So, if you have spaces in both your binpath and your path to –defaults-file, then the following syntax will work for you (all on a single line):

sc create MySQLEnterpriseMonitorAgent
binpath= ""C:Program FilesMySQLEnterpriseAgentbinmysql-monitor-agent.exe"
--defaults-file="C:Program FilesMySQLEnterpriseAgentetcmysql-monitor-agent.ini""
DisplayName= "MySQL Enterprise Monitor Agent" start= "auto"

Note that you could easily use the exact same syntax to install a Windows service for the MySQL server itself (using mysqld.exe and my.ini instead, along with their correct paths). Similarly, this could be also used to create a Windows service for MySQL Proxy too. Just point binpath to mysql-proxy-svc.exe, and instead of –defaults-file=, use –proxy-lua-script= (in fact, I actually had a post on this close to a year ago, but my example only had one path that contained a space, so the above syntax was not necessary).

At any rate, the above command should output somthing similar to the following:

[SC] CreateService SUCCESS

For reference, here is my terminal session:

C:UsersChris>sc create MySQLEnterpriseMonitorAgent
binpath= ""C:Program FilesMySQLEnterpriseAgentbinmysql-monitor-agent.exe"
--defaults-file="C:Program FilesMySQLEnterpriseAgentetcmysql-monitor-agent.ini""
DisplayName= "MySQL Enterprise Monitor Agent" start= "auto"
[SC] CreateService SUCCESS

Hope this helps.

Tags: , , , , , , ,

2 Responses to “Syntax for Creating a Windows Service for MySQL (when there are 2 paths which both contain spaces)”

  1. [...] Syntax for Creating a Windows Service for MySQL (when there are 2 … agent, enterprise, for-mysqld, have-troubles, proper-syntax, seen-people, services-on-windows, [...]

  2. [...] This post was mentioned on Twitter by planetmysql, Angel Moo May, Programación Web, SQLManager, Zuissi and others. Zuissi said: MySQL: Syntax for Creating a Windows Service for MySQL (when there are 2 paths which both contain spaces): Numerou… http://bit.ly/bfPkOb [...]


Period Panties by Period Panteez Menstrual Underwear Menstruation PMS Panty