Connect to online MySQL from localhost

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
hypedupdawg
Forum Commoner
Posts: 74
Joined: Sat Apr 10, 2010 5:21 am

Connect to online MySQL from localhost

Post by hypedupdawg »

I have recently looked at utilizing the MySQL aspects on my webserver, and have come across this rather annoying problem - when I try to connect from my localhost testing server, I get this error;
Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'sql313.byethost17.com' (10060)
...however, from my proper server it connects straight away. I have looked around, and cannot find any mention of this problem anywhere. The syntax I am using is the standard:

Code: Select all

<?php
mysql_connect("sql313.byethost17.com","username", "password") or die(mysql_error());
?>
Is there another command I need to add to get it to connect to an online server? Is it my firewall / ports interfering? Will I have egg on my face tomorrow for a blatant error?

I am using the server Byethost; I don't know if it makes a difference.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Connect to online MySQL from localhost

Post by John Cartwright »

Generally the servers are setup to only allow specific hosts to connect. Therefore, you need to contact your host, or if you have cpanel (among other control panels) you can usually whitelist additional hosts.

Moved to Installation and Configuration.
Doug G
Forum Contributor
Posts: 282
Joined: Sun Sep 09, 2007 6:27 pm

Re: Connect to online MySQL from localhost

Post by Doug G »

Try connecting from your local workstation command line mysql program. You'll see more info about what's wrong.

Also as mentioned contact your host. My hosting company allows remote mysql server access, but not all hosts allow such access. Some, as mentioned, restrict access to specific remote machines. Some hosts don't allow remote access at all, and expect you to do all your db administration from phpMyAdmin or some other program that runs on their server.
Post Reply