Web Hosting

Please find below our list of Web Hosting guides to help with your hosting account.

How to connect to a MySQL database from an external host

This article was posted in: Web Hosting

MySQL server runs on each local hosting server on TCP Port 3306 (the standard port for mysql). When your web scripts connect to MySQL they can do so using simply localhost as the server name. However, you can also connect to your databases from an external host, such as your home PC, office, or another web server.

PREPARING TO CONNECT

Due to PCI/Security considerations, there are two stages involved in granting your IP address access to the MySQL service.

1.) Granting access through our firewall.
2.) Granting access within MySQL itself to your external IP address.

You will need the IP address of the host you are connecting FROM. You can determine this by browsing to http://viewmyip.co.uk

This guide assumes you have already successfully logged into cPanel.


Step 1 - Firewall access

Create a support ticket and request access to MySQL through the server's firewall clearly stating your IP address.

If your IP address is not static, and changes on a regular basis, then it will be impractical as we will need to constantly update our firewall.

The need for firewall access can be circumvented if you are able to open an SSH tunnel to your account and connect to MySQL via the tunnel. However, this is an advanced topic for most, although we are happy to offer advice, and there is a guide here which explains how to connect to MySQL using an SSH tunnel.


Step 2 - MySQL access

Click on the Remote MySQL icon in the DATABASES section of cPanel.


Step 3

Enter your IP address in the Add Access Host field provided and click the Add Host button.That will grant access to MySQL for the host you provided.

BE AWARE THAT THIS METHOD OF CONNECTION IS NOT SECURE - Credentials are passed unencrypted, so are open to eavesdropping attacks. For greater security we recommend you connect using an SSH tunnel.