ODBC Driver for MySQL

Connection to MySQL via HTTP Tunnel in ODBC Driver

Connection through HTTP tunnel

Sometimes client machines are shielded by a firewall that does not allow you to connect to server directly at the specified port. If the firewall allows HTTP connections, you can use HTTP tunneling based on the PHP script.

An example of the web script tunneling usage can be the following: you have a remote website, and access to its database through the port of the database server is forbidden. Only access through HTTP port 80 is allowed, and you need to access the database from a remote computer, like when using usual direct connection.

To start using HTTP tunneling, you should deploy the Tunneling script. The php script must be available through the HTTP protocol. You can verify it is accessible for a web. For this enter the http://www.domain.com/tunnel.php address to a web browser and check the result. The only requirement to the server is PHP 5 support.

P.S.: tunnel.php is provided along with ODBC Driver for MySQL. It is available at the driver installation path, in the http folder, by default: C:\Program Files (x86)\Devart\ODBC\MySQL\http\tunnel.php

To connect to the database, you should set connection parameters for usual direct connection and set the following parameters specific for the HTTP tunneling:

Using ODBC Data Source Administrator


HTTP Options Description

Option Description

Use Http

Enables or disables HTTP tunneling.

Http Url

Holds the url of the tunneling PHP script.

Http Username

Set these properties if the access to the website folder with the script is available only for registered users authenticated with user name and password.

Http Password

Http Trust Server Certificate

This option specifies whether or not the driver should trust the server certificate when connecting to the server. The default value is False – the driver won't trust the server certificate and will verify validity of the server certificate instead. If set to True, the driver will trust the server certificate.

Example Connection String

User ID=root;Password=root;Data Source=localhost;Database=test;Use Http=true;Url=http://server/tunnel.php;Http Username=HttpUser;Http Password=HttpPassword;

Connection through proxy and HTTP tunnel

Consider the previous case with one more complication.

HTTP tunneling server is not directly accessible from client machine. For example, the client can reach the server only through proxy at address, which listens on port 3128. In this case in addition to the HTTP options, you have to setup Proxy options as follows:


Proxy Options Description

Option Description

Proxy Host Name

Holds the host name or IP address of the proxy server to connect to.

Proxy Port

Used to specify the port number for TCP/IP connection with proxy server.

Proxy Username

Holds the proxy server account name.

Proxy Password

Holds the password for the proxy server account.

Example Connection String

User ID=root;Password=root;Data Source=;Port=3307;Database=test;Use Http=true;Url=http://server/tunnel.php;Proxy Hostname=;Proxy Port=3128;Proxy User=ProxyUser;Proxy Password=ProxyPassword;

Additional information

Technically speaking, there is one more way to tunnel network traffic. The Secure Shell forwarding, or SSH, can be used for forwarding data. However, main purpose of SSH is traffic encryption rather than avoiding firewalls or network configuration problems. The SSH Connection article describes how to use SSH protocol in ODBC Driver for MySQL.

Keep in mind that traffic tunneling or encryption always increase CPU usage and network load. It is recommended that you use direct connection whenever possible.

© 2015-2020 Devart. All Rights Reserved. Request Support ODBC Forum Provide Feedback