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 wpf中在模版中寻找元素
  • ¥15 MFC平台生成指定圆
  • ¥15 jmeter出现403
  • ¥500 求华为P30PRO手机硬盘数据恢复
  • ¥15 关于#vscode#的问题:ESP32开发板对接MQTT实现小灯泡的开关
  • ¥15 TMC2209串口模式下读取不到寄存器的值串口助手蓝色字体是发过去的消息,绿色字体是收到的消息,第二行发送读取寄存器的指令但是没有读取到寄存器的值串口助手如下图:接线如下图,如何解决?
  • ¥15 怎样删除 右键菜单里的 剪切(T)和复制(C)
  • ¥15 高通安卓11提取完整线刷包软件,或者优博讯dt50顺丰刷机包
  • ¥20 C,有个译码器,换了信道就跑不出原来数据
  • ¥15 MIMIC数据库安装问题