mysql remote server connection - other threads dont help

davestacey

Member
Nov 10, 2005
13
0
151
Hi,

I am trying to connect to my own server (mysql), from another server i just bought.

I searched the net to no avail, and this thread doesnt work for me (http://forums.cpanel.net/showthread.php?t=78345)

I have added the new servers ip to my old servers firewall, and it still wont connect, i get this error.

Can't connect to MySQL server on '*.*.*.*' (4)
This is the php code i am using....

// Database configuration details:
$dbHost = "*.*.*.*:3306";
$dbUser = "user";
$dbPass = "password";
$dbName = "database";

// Connect to MySQL:
if (!$dbase = @mysql_connect($dbHost, $dbUser, $dbPass))
{
die(mysql_error());
}

Any simple instructions on how to do this please?

Thanks!
 

cPanelKenneth

cPanel Development
Staff member
Apr 7, 2006
4,577
51
308
cPanel Access Level
Root Administrator
1. Is MySQL on your SQL server configured to listen on TCP port 3306?

2. Is your MySQL server accessible from your new server (e.g. you can ping the MySQL server from your new cPanel server)?

3. Is the access GRANT for the MySQL user correct (e.g. the Host field either has % or the IP address/hostname connecting from)?
 

davestacey

Member
Nov 10, 2005
13
0
151
1. Is MySQL on your SQL server configured to listen on TCP port 3306?

2. Is your MySQL server accessible from your new server (e.g. you can ping the MySQL server from your new cPanel server)?

3. Is the access GRANT for the MySQL user correct (e.g. the Host field either has % or the IP address/hostname connecting from)?
Hi Kenneth,

Thanks for taking the time to answer my thread.

1. yes, port 3306 is open in the csf firewall
2. the new server is a shared non cpanel server, so i got the server admin to ping on my behalf and it pinged ok.
3. yes this is setup


Are there any other tests i can do from the new server to see if it can connect to the sql server?
 
Last edited:

[email protected]

Registered
May 31, 2007
4
0
151
Try this from new server, and see if you are able to connect.

telnet oldserver.com 3306

(Replace oldserver.com with your old servername/IP)
 

anton_latvia

Well-Known Member
PartnerNOC
May 11, 2004
378
10
168
Latvia
cPanel Access Level
Root Administrator
There are many things that can happen - firewall on your local server, firewall on the new serve blocking outgoing connections (do you have ConfigServer Firewall installed or may be default iptables rules are enabled?). Then your mySQL server might deny network connections, please give us content of /etc/my.cnf. Then - did you try to connect through shell? (mysql -h REMOTE_ADDR -u USERNAME -p). If this does not work - what exact error do you get?

Anton.