Possible Duplicate:
how to understand “can't connect” mysql error messages?
I have attempted to follow just about every tutorial I could find on this subject, to no avail. I'm trying to connect to a remote MySQL database through PHP, but it seems like the connection is timing out or something. This is my PHP code:
$link = mysql_connect('remote-server-ip:3306', $username, $password);
if($link){
echo "Connected.";
}else{
echo "Not connected: ".mysql_error();
}
When I browse to that page, it loads for about 30 seconds before displaying this:
Warning: mysql_connect(): Can't connect to MySQL server on 'remote-server-ip' (4) in /var/www/vhosts/*****/httpdocs/*****/*****.php on line 6
Here's what I've done on the remote server to try to allow this connection:
- Added IPtables rules to allow connections from my server.
- Set my.cnf to listen to all TCP requests
- Added users to my database that can connect from my server's IP
Still nothing seems to be working. I could really use some help here.