我正在尝试使用PHP连接连接到另一台服务器上的MySQL数据库 . 我收到以下错误,无法弄明白 .
This is the error when I include the port:
警告:mysqli_connect()[function.mysqli-connect] :( HY000 / 2005):/ home / xxxxxx / public_html / tools /中未知的MySQL服务器主机'xxxxxx.db.0000095.hostedresource.com:3306'(25)第3行包含/ db_connect.php无法连接到MySQL:未知的MySQL服务器主机'xxxxxxxx.db.0000095.hostedresource.com:3306'(25)
This is my error when not using the port:
警告:mysqli_connect()[function.mysqli-connect] :( HY000 / 2003):/ home / xxxxxx / public_html / tools / include /中的未知MySQL服务器主机'xxxxxx.db.0000095.hostedresource.com'(110)第3行的db_connect.php无法连接到MySQL:未知的MySQL服务器主机'xxxxxxxx.db.0000095.hostedresource.com'(110)
This is my db_connect file:
<?
$con=mysqli_connect("xxxxxx.db.0000095.hostedresource.com","xxcorrectxx","xxcorrectxx",
"xxcorrectxx");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
这是服务器上可能存在的防火墙问题我有包含文件吗?此db连接文件在我拥有的其他域上正常工作 . 如果你能看到解决方法,请告诉我 . 谢谢 .
2 回答
根据documentation of mysqli_connect(),端口是一个附加参数 .
可能是防火墙阻塞了流量 .
通常,MySQL端口不对公共访问开放;它仅适用于本地网络 . 此外,DB用户可能在MySQL用户权限表中具有
localhost
或IP而不是任何主机(%
) .您可以通过telnet验证远程服务器中的3306端口 .