0

I'm trying to connect to a remote database on a server which is accessed through cPanel.

I created a user name and associated it with a database. I'm using:

I'm confused on the host name to use. I tried using the Main Domain name in the left menu panel in cPanel with the port number 3306 but it wouldn't work. I used the shared IP as well with the port number that that wouldn't work as well. I have added my local machine IP to the remote databases page in the cPanel as was told in a post but finally I'm not able to connect to the database.

On echoing the mysql_error(), I get:

Can't connect to MySQL server on 'host_name' (4)

Any help would be great!

8
  • 1
    Are you sure the database is listening external? Maybe it's configured to just accept connections from localhost. Commented Jan 20, 2014 at 12:43
  • @MarcelBalzer How do I check if database is listening external? I tried $telnet my_shared_ip:3306 And it gives - Could not resolve : Name or service unknown Commented Jan 20, 2014 at 12:46
  • And is telnet get a connection? Commented Jan 20, 2014 at 12:47
  • telnet is throwing an error could not resolve: ip_address:3306/telnet: Name or service not known Commented Jan 20, 2014 at 12:54
  • You don't resolve IP addresses, do you?? You resolve hostnames to ip addresses, and ips get routed, but not resolved. The only case IP addresses get resolved is in mail spam detectors by the reverse DNS. Commented Jan 20, 2014 at 12:55

1 Answer 1

1

your hosting site will specify which name should be used for the host

in hostinghood.com they says that to use localhost itself as host name

so check what your hosting site says about it

Sign up to request clarification or add additional context in comments.

2 Comments

I don't think a remote connection can be achieved by using localhost as the hostname. It is used for the applications hosted on the same hosting provider. What I'm trying to achieve here is a remote connection to the hosting provider's database.
i know it but i said that hostinghood.com says to use it for our easyness thay had made the settings like that.if you have any doubt try hosting in hostinghood.com other hosting sites have different name for the host

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.