Spec-Zone .ru
спецификации, руководства, описания, API

15.7.2.4. Setting Up MySQL Proxy as a Windows Service

The MySQL distribution on Windows includes the mysql-proxy-svc.exe command that enables a MySQL Proxy instance to be managed by the Windows service control manager. You can control the service, including automatically starting and stopping it during boot, reboot and shutdown, without separately running the MySQL Proxy application.

To set up a MySQL Proxy service, use the sc command to create a new service using the MySQL Proxy service command. Specify the MySQL Proxy options on the sc command line, and identify the service with a unique name. For example, to configure a new MySQL Proxy instance that will automatically start when your system boots, redirecting queries to the local MySQL server:

C:\> sc create "Proxy" DisplayName= "MySQL Proxy"
        start= "auto" »  binPath= "C:\Program
        Files\MySQL\mysql-proxy-0.8.2\bin\mysql-proxy-svc.exe »  --proxy-backend-addresses=127.0.0.1:3306"
Note

The space following the equal sign after each property is required; failure to include it results in an error.

The preceding command creates a new service called Proxy. You can start and stop the service using the net start|stop command with the service name. The service is not automatically started after it is created. To start the service:

C:\> net start proxyThe MySQL Proxy service is starting.The MySQL Proxy service was started successfully.

You can specify additional command-line options to the sc command. You can also set up multiple MySQL Proxy services on the same machine (providing they are configured to listen on different ports and/or IP addresses.

You can delete a service that you have created:

C:\> sc delete proxy

For more information on creating services using sc, see How to create a Windows service by using Sc.exe.