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 advanceinstaller对话框设置
    • ¥100 正常上网,内部网页无法打开
    • ¥15 组件库引入并使用在若依框架未展示
    • ¥149 关于#使用python 的Flash Echarts+ajax+mysql动态数据实现饼图#的问题,请各位专家解答!
    • ¥15 RichTextBox中追加文本时报错
    • ¥15 关于c语言的学习问题
    • ¥15 activity升级到flowable工作流act_ge_bytearray的草稿json数据复制到act_de_model 的model_editor_json的脚本
    • ¥15 cvi使用CreateThread创建线程时,出现存储空间不足无法处理此命令的错误
    • ¥15 求苹果推信imessage批量推信技术
    • ¥15 ubuntu 22.04 系统盘空间不足。隐藏的docker空间占用?(相关搜索:移动硬盘|管理系统)