In this tutorial:

If you need to connect to your database using third party software that does not run on the server, such as a MySQL client on your desktop a remote MySQL connection can be made. First you will have to allow the connection from within cPanel for the IP address you are connecting from. 

What program do I use to connect Remotely?

There are a few programs you can use to connect remotely to your database. HTML editors like DreamWeaver can connect to your databases remotely as well. There are Free Open Source programs you can use like MySQL Workbench or or Heidi SQL. Below are some links to programs you can use to connect to your databases remotely.

Adding an IP address to allow a remote MySQL connection

db_1First, you will need to make sure you have the IP address that will be accessing the database. These rules protect the database by only accepting external connections that you have set up. If you are connecting to a database from your current connection, you can obtain your current IP address by visiting this link: current IP address. Once you have the IP address that you wish to connect remotely, log into cPanel and click on "Remote MySQL" under the Databases Heading.

db_2Next, you'll need to add the IP address into the field on the page and select "Add Host".

Now, since you have added the IP address to remote MySQL connections you will be able to connect to the databases. You can add as many IP addresses as you need.

Using a Wildcard to allow all IP's

You may find you need to use a wildcard if your IP address changes regularly. You can add a wildcard by using the % symbol. This will add all IP addresses in that range.

If you want to list all IP addresses in the range 174.77.92.1 to 174.77.92.255 you'd add the IP address 174.77.92.%.

Troubleshooting Remote connection issues

If you are using your preferred remote connection tool and suddenly it will not connect. This error is known as a 1045 and usually reads similar to '1045 - access denied for user'. If you are getting this error, there are a couple of things listed below that you may want to check.

Check your cPanel password

Many people connect remotely using their cPanel username and password as opposed to creating a single administrative user to add to the databases. This is not the preferred method, however if you do use the cPanel username and you are now getting a connection error, chances are you recently changed the cPanel password and have not changed it in the Remote connection software settings. Change the password there and you should be able to connect once again.

Check to see if connecting IP has changed

Not all of us are blessed with static IP addresses. From time to time your ISP (Internet Service Provider) may change your public IP address. If that is the case, you may find yourself unable to connect remotely via your preferred software. First, check your IP address by going to Google.com and searching for the term IP. You can also find your current IP address by clicking here.

Once you know your current IP address, go back and make sure that it is in the list of allowed IP addresses for your Remote MySQL settings. If you find it was not in the list and add the new one, you should then be able to connect remotely.

If you need further assistance with connecting to a database remotely please contact our support department

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question
2012-11-12 6:40 pm
You should mention how we find out HOW to access our MySQL databases from the remote location? What address do we use from the remote location to access the MySQL database?
Staff
17,351 Points
2012-11-12 7:18 pm
Hello Airquality,

Apologies, but this is a general article about making a remote connection to a database. Access to the database is generally based on the URL used to get to the server, and the user name and password assigned to the database you're trying to access. You will need to provide your IP address in order to allow the access through the firewall. This access is ONLY for database access (which occurs by default through a specific port). All of this is determined the Remote MySQL setup.

If you have any further questions, please contact technical support or leave a comment at the bottom of the page.

Regards,

Arnel C.
2013-09-18 12:14 am
As you said use % as Wildcard then , how to allow all remote connection ?
Staff
9,162 Points
2013-09-18 8:37 am
If you want to allow all IP addresses to connect to a remote MySQL server, you would use wildwards such as %.%.%.% which would allow any IP address to connect. Doing so, however, is a very large security risk and I highly recommend against it.
n/a Points
2014-04-18 6:32 am

I'm trying to synchronize data tables  local install (mamp)  phpmysqladmin and it failes. I'm unable to troblehoot with telnet connection.

Upon telneting to my site, it ask only for password and not a username.  I already assigned username and password for specific database.  Which password is it waiting for? cpanel, my domain login to inmotion, or something else? 

After several failed attempts, i'm not allowed connet back to my ip address and get a packet out of order.

 

The error message attempting to connect:

5.5.36-cll?r"L=*W\?*?<P]cZwg"n(mysql_native_password (mypasswordhere)!#08S01Got packets out of orderConnection closed by foreign host.

?Host '107-223-112-160.lightspeed.sndgca.sbcglobal.net' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'Connection closed by foreign host.

Do i have the 'mysqladmin flush-hosts ability? It doesn't work in sql screen and looks like a command prompt from the unix shell.  I don't have access directly to that unix shell that i'm aware of.

 

Example Edited log below.

Joeys-MacAir:cgi-bin boun619$ telnet 70.39.999.999 3306Trying 70.39.999.999...Connected to ecbiz999999.inmotionhosting.com.Escape character is '^]'.N5.5.36-cllf?=Z/z:Rm?(u6KVOh=9E-Rmysql_native_password

Connection closed by foreign host.

 

Any Ideas?

-Joey

Staff
9,162 Points
2014-04-18 7:46 am
First, you will not be able to telnet into your account. You will have to use a remote MySQL connection instead. When logging in remotely, you will be using the username and password to the MySQL user that is accessing the database that you want to connect to. This is something that you would have created within cPanel. As for the flush-hosts issue, this is caused by too many bad connections to the server and would need to be resolved by contacting technical support.
n/a Points
2014-06-17 6:55 pm

This doesn't explain how to connect - i.e. what should the mysql_connect look like. I can't get it to work and all I can find are platitudes.

Staff
9,968 Points
2014-06-17 7:17 pm
Hello Ron,

This guide just covers how to allow a remote MySQL connection into the server. If you're looking for how to connect to MySQL from PHP, we do have a guide on connecting to MySQL with PHP that does go over mysql_connect with this bit of code in the second step of the guide:

$con = mysql_connect("localhost","inmoti6_myuser","mypassword");


Please let us know if you had any other questions at all.

- Jacob
n/a Points
2014-06-17 7:58 pm

I'm trying to do a remote mysql access - and I can't get it to work. There's obviously more to it than is explained here.

n/a Points
2014-06-17 8:14 pm

I know how to do a local connection. I can't get a remote connection to work

Staff
9,968 Points
2014-06-17 8:36 pm
Hello Ron,

What code are you trying to currently use, and is it resulting in any errors? Also are you allowing the remote IP address of the server that you're running your PHP script from? Because that's the one that will need to be added, and not your local IP if the PHP server is running from another server.

There is an explanation as well as examples of mysql_connect from the PHP.net site.

If your script works locally but not remotely, I'd try this basic example:

<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>


After ensuring that the localhost variable is set to the server that is hosting your MySQL database, and also that the mysql_user, and mysql_password settings are correct what error is it giving back after the Could not connect: text?

- Jacob
n/a Points
2014-06-17 8:42 pm

The error I'm getting is this:

Lost connection to MySQL server at 'reading initial communication packet', system error: 110

and yea the local connection works. What's this about a different password for remote connection? How do I find that?

Staff
9,968 Points
2014-06-17 9:24 pm
Hello again Ron,

I'd assume either the server address you're using, or the username and password are incorrect based off that error. Either that or possibly you have a local firewall running that is preventing the outbound connection on port 3306.

Yes you do need a different username / password typically for a remote connection. This would be the database username and password that you setup on the remote server. For instance you need to create and attach a database user to a database in order to remotely connect to it.

- Jacob
n/a Points
2014-06-30 8:45 am

Hello Jacob (or colleague)

I'm trying to connect to my remote MySQL database using a JAVA program (that I used to process data from a CSV file). It all works fine when I connect to my local database, but when I change the settings to access the remote database, I can't connect.  I discovered this morning that I don't have SSH access to the remote database; does this mean that I will not be able to connect remotely using my JAVA app? Will I have to use something like WorkBench or Heidi? (I have got PHPMyAdmin access through cPanel, but it would be much quicker to load the database directly from the JAVA app.)

Any help appreciated.

Staff
19,557 Points
2014-06-30 9:10 am
Hello Steve,

As long as your IP is added to the Remote MySQL Connection tool and the settings are correct, there should be no issue with you connecting to the database remotely. You may opt to use Workbench, NaviCat, or Heidi as well, but they require the same setup as your Java app would. It may be good to test with one of those other applications as well as part of the troubleshooting process.

Kindest Regards,
Scott M
n/a Points
2014-06-30 11:31 am

Thanks for the quick reply Scott.

I can connect fine through a dummy php page I uploaded (using an example on IMH site), but still can't connect using the JAVA app. Could you tell me what format the domain should be:-

Eg. "jdbc:mysql://www.mydomain.org.uk:3306"

Steve

Staff
19,557 Points
2014-06-30 11:56 am
Hello Steve,

Within the snippet you provided, have you tried using the IP address instead of the domain name? Also, are you adding /dbname at the end before you provide the username and password? It should appear something like this:
jdbc:mysql://123.123.123.123/db_name, db_user, password

If not, please let me know any error text you are receiving as well.

Kindest Regards,
Scott M
n/a Points
2014-07-15 4:34 pm

String host= "jdbc:mysql://%.%.%.%/a21_senkwaepos";

String uname = "username";

String upass = "password";

        try {

            Class.forName("com.mysql.jdbc.Driver");

            con = DriverManager.getConnection(host, uname, upass);

am having error messages with the connection to the database..

Staff
9,968 Points
2014-07-15 4:58 pm
Hello Fish,

What is the error that you're getting about problems connecting to the database? It's hard to troubleshoot without seeing your full code or the specific error. I would make sure to reference the connecting to MySQL using JDBC guide from MySQL.

Also you want to make sure that your host is a valid entry that your Java application can connect remotely to. So I'm not sure if you were just using jdbc:mysql://%.%.%.%/a21_senkwaepos as an example. But that needs to be a valid IP address or hostname:

String url = "jdbc:mysql://localhost/test";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
Connection conn = DriverManager.getConnection (url, "username", "password");



- Jacob

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

21 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!