mySQL connection problems.

Associate
Joined
1 Jun 2007
Posts
827
I have a script which contacts a mySQL server for some data.

I have 2 servers. Different companys.

Each has a backup of the data. If one fails it contacts the other.

Now one server on Vidahost works correctly even if it fails. But the other one cant contact the Vidahost mySQL server when it fails.

This is the error:

Warning: mysqli_connect(): (HY000/2003): Can't connect to MySQL server on 'host name' (110) in test.php

Ive added the IP address to the remote mySQL connections.

I can connect to both servers from my home PC running php.

Any ideas ?
 
Last edited:
Do you have root access to the server that MySQL is hosted on? And is it RHEL/Centos?

If so, SELinux can usually cause problems with remote connections. The following usually rectifies it.

Code:
setsebool -P httpd_can_network_connect=1

If not, are you using the non-standard port? Maybe post the code you're using to connect (without the credentials of course).
 
Nothing fancy this extracted from the file:

$dbcon=mysqli_connect($DBHOSTNAME,$DBUSERNAME,$DBPASSW,$DBDATABASE);

The script works when run from localhost and on VIdahost.

I dont have root access but I do have ssh access on the problematic server.

Not sure if they use SELinux. Will dig further.

Update:

Its Red Hat 4.1.2-52. Linux version 2.6.32
 
Last edited:
Yeah they are the same.

The command line mySQL doesnt even connect. I said to them support that it seems like a firewall is blocking the connection but they say they are allowing mysql connections.
 
Sounds like a firewall issue, have you tried changing the port on your mysql server? I think the default is 3306, or suggest to support to open that port?

Doubt it would make any difference but can you get a PDO connection?
 
Found out the problem their machine had multiple IP address which I didnt know about.

I need to allow access to the other IP address. Everything is fine now.
 
Back
Top Bottom