Contact Support : +64 220 256 070

Aimvm
Blog

How to connect to the Mysql database server from a remote machine?

Posted on: August 29, 2014

This lesson will teach you on how to connect to a Mysql server remotely.

The connections to a Mysql database server is usally done using connection string which is a sequence of variables which will address a specific database and allow you to connect your code to your MySQL database.

Example of a php script:

$dbh=mysql_connect (“localhost”, “cpuser_dbuser“, “password“) or die (‘I cannot connect to the database because: ‘ . mysql_error());
mysql_select_db (“cpuser_db“);

As default all the IPs will be blocked on the Mysql server for security purpose and we need to manually enable it.

1) Login to the cPanel account. Please note that the database you want to connect should be concerned with this account.

2) In the search box type ‘remote’ and hit enter. Now you will see the Remote Mysql option.

1

2) Click on the Remote Mysql option.

3) In the Host field, type in the connecting IP address. You can find the IP address of the machine by accessing here

2

4) Click on ‘Add Host’ and you will see the confirmation in a new page.

3

You should now be able to connect remotely to your database.

If you find any difficulties for making the connection please contact our support department.

 

 

Search Blog