Reputation: 45
I am trying to connect to MySQL database which is on another server using PHP connection. I am getting the following error and can not figure it out.
This is the error when I include the port:
Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2005): Unknown MySQL server host 'xxxxxx.db.0000095.hostedresource.com:3306' (25) in /home/xxxxxx/public_html/tools/include/db_connect.php on line 3 Failed to connect to MySQL: Unknown MySQL server host 'xxxxxxxx.db.0000095.hostedresource.com:3306' (25)
Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2003): Unknown MySQL server host 'xxxxxx.db.0000095.hostedresource.com' (110) in /home/xxxxxx/public_html/tools/include/db_connect.php on line 3 Failed to connect to MySQL: Unknown MySQL server host 'xxxxxxxx.db.0000095.hostedresource.com' (110)
<?
$con=mysqli_connect("xxxxxx.db.0000095.hostedresource.com","xxcorrectxx","xxcorrectxx",
"xxcorrectxx");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
Upvotes: 1
Views: 3827
Reputation: 17797
According to the documentation of mysqli_connect() the port is an additional parameter.
$con=mysqli_connect("xxxxxx.db.0000095.hostedresource.com",
"xxcorrectxx","xxcorrectxx", "xxcorrectxx", 3306);
Upvotes: 0
Reputation: 54212
The traffic is blocked by firewall, probably.
Normally MySQL port is NOT open to public access; it is available for local network only. Moreover, the DB user is probably having localhost
or an IP instead of any host ( %
) in the MySQL user permission table.
You can verify by telnet to 3306 port in the remote server.
Upvotes: 4