doushangxianq07480 2014-11-12 23:08
浏览 62
已采纳

通过PHP从GoDaddy连接到远程AWS MySQL

I'm having an issue connecting to a remote MySQL server that is hosted by Amazon Web Services. I can connect to this MySQL server from virtually any other computer, but for some reason I cannot get it to be pulled into my PHP that is hosted on GoDaddy.

Here is the PHP code:

$cxn = mysql_connect($host,$user,$passwd,$dbname)
         or die("Query died: Cannot connect.");

I've added the host name for the MySQL server into GoDaddy's CPANEL > Remote MySQL Access Hosts. I know that the variables are correct, because I've tested this on another server and everything works fine.

I've been on the phone with GoDaddy twice now, and all they've said is to try asking a forum (apart from adding the MySQL host to the Remote Access Hosts page).

I've checked the security group for the AWS MySQL and made sure that it is open to the GoDaddy's hosted IP address...

I'm just not sure what else to do! Why isn't this working on GoDaddy's server when it was working just fine on another??

MySQL v5.6 --> on AWS PHP v5.4 --> on GoDaddy

  • 写回答

1条回答 默认 最新

  • dongsi5381 2014-11-13 01:16
    关注

    Based on the the information in the question and the comments, it is clear that GoDaddy's network operations team does not allow outgoing TCP connection requests on port 3306 (that's MySQL's default port).

    That means you can't originate a connection from a program running on a GoDaddy server to a MySQL server located elsewhere. If you do, it will stall until the TCP connection timeout elapses.

    What can you do about this?

    1. Ask them to allow your outgoing 3306 traffic. (Not likely, I suspect. Their business model doesn't afford much per-customer network engineering work.)
    2. Try getting your MySQL server to listen on some other port, perhaps 8000. 8080, or another of the commonly used "alternative" http ports. Those might not be blocked. Then use

      mysql_connect("$host:$port",$user,$passwd,$dbname)

    to connect.

    You'll need to look up how to get an AWS-resident MySQL server to listen on a nonstandard port.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料