duanlu8613 2013-12-23 13:00
浏览 76

使用php跨服务器的mysqli连接错误

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)


This is my error when not using the port:

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)


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();
}
?>


Is this a possible firewall issue on the server I have the include file on? This db connect file is working fine on other domains I have. Please tell me if you can see a fix for this. Thank you.
  • 写回答

2条回答 默认 最新

  • dongsi2317 2013-12-23 13:02
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)