Sometimes you find yourself backed into a technology corner, caused by a horrible combination of design choices made over a period of time.

For me, I experienced this recently when desktop clients needed to access a MySQL database via ODBC. Simple, right? Not so much. The custom application was hard wired to talk to a MySQL Server on a DNS record which not only happened to be the public web address, but also the FQDN of the Active Directory. When it came time to separate domain controller from web and database server, chaos ensued (not quite, but there was a fair amount of groaning as this was discovered).

Sadly, we couldn’t update the application at this point. It’s slated for replacement, but not now. We need a work around!

The solution was to install the MySQL Proxy service on all of the Domain Controllers. This means than whenever a database request was received by the service, it was sent to the real domain controller.

MySQL Proxy has no GUI, and is setup entirely via the command line. It’s a handy little utility that can do a lot more than what we need it for (think: load balancing, query re-writing, and a whole heap more)

To install it, copy the binaries and their dependencies to a folder of your choosing. Then you can go ahead and install the service via the command line. This is the command I ran. It takes requests on the local IP 192.168.13.11 using port 3306 and passes them to port 192.168.13.100 using port 3306. (3306 is the default MySQL port)

sc create “MySQL Proxy” DisplayName= “MySQL Proxy” start= “auto” binPath= “C:\Program Files\MySQL\mysql-proxy\bin\mysql-proxy-svc.exe –proxy-address=192.168.13.11:3306 –proxy-backend-addresses=192.168.13.100:3306”

Before you install this service, you may want to first run this as a simple application to test your parameters work. It is a lot easier to debug this way. You can run “C:\Program Files\MySQL\mysql-proxy\bin\mysql-proxy.exe” –proxy-address=192.168.13.11:3306 –proxy-backend-addresses=192.168.13.100:3306 from the command line and see if it works as you expected. If not, tweak the parameters and try again.

There are a lot of parameter options. You can read the configuration manual to find out more about what each of the commands do.

Also, make sure you open up the correct ports on your Windows Firewall to allow incoming traffic.

If you make a mistake with installing the service, you can edit it in the registry. Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MySQL Proxy. Just make sure the service is stopped when you do this.

Once you’re done, make sure you set the service to automatically run via the Services MMC.

Get the Broadcast Technology Newsletter

Sign up for the email newsletter about media and technology. Sent irregularly. No spam.

I'm Anthony Eden, and I'm a IT Professional, Broadcast Technician, Software Developer, and Solutions Engineer. I've been working in broadcast media since 2008, and developing software and websites for just as long. Right now, I provide freelance services through Media Realm - in particular, to the media and not-for-profit industries.

Follow Anthony on Twitter: @anthony_eden