ISPA Winner 2018 16 Years of Krystal

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.


Before getting started you will need the IP address of the host you are connecting FROM, this can be done by browsing to on the device in question or asking the provider of the server your connecting from.

This guide assumes you have already successfully logged into cPanel.

Step 1 - Firewall access

Due to changes in how we handle remote MySQL connections, we no longer need to manually whitelist IP addresses in our firewall. This means the only consideration you need to apply at this stage is whether your IP address is static or dynamic.

If your IP address is not static, and changes on a regular basis, then you will need to keep in mind you will need to add each new IP address following on from Step 2, as such we recommend looking into an SSH tunnel so you can connect to MySQL via the SSH tunnel.

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.