douke3442 2014-09-12 11:13
浏览 107
已采纳

AWS从PHP访问VPC中的RDS

I am on AWS with a lamp stack connecting to RDS.
I am able to connect from MySQL Workbench using SSH to RDS through amazons security groups.
But ... now that i need to connect from the outside world using PHP, I seem to be having some issues.

Normally i would connect to RDS using sqli like this:

$dbName = "mydb.xxxxxxxxxx.us-xxxx-1.rds.amazonaws.com";
$dbTable = "mytable";
$dbUser = "myusername";
$dbPass = "xxxxxxx";

But since the new instance is on a VPC on RDS public accessibility is not available.

I changed $dbName = 'xx.xxx.xx.xxx:3306' which is the public ip of my EC2 instance, but i get an error: mysqli_real_connect(): (HY000/2005): Unknown MySQL server host 'xx.xxx.xx.xxx:3306'

I am following this guide but seem to be unsuccessful at connecting.

I think I am not doing this part correctly

Create a second VPC security group (for example, "sg-dbsrv1") and create a new rule by specifying the VPC security group you created in step 1 ("sg-appsrv1") as the source.

Any help would be very appreciated, thank you.

  • 写回答

1条回答 默认 最新

  • dongxiezhi0590 2014-09-12 11:37
    关注

    In the AWS console you have to either append your IP to the existing security group or create another security group with your IP and add that group to your instance.

    RDS instances are not accessible except by hostname (especially if you're running Multi-AZ).

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

报告相同问题?

悬赏问题

  • ¥15 有人帮看看这个问题的嘛
  • ¥15 STM32悬赏求解答,ai不要来解答
  • ¥15 Mysql 一张表同时多人查询和插入怎么防止死锁
  • ¥20 centos6.7 安装libevent库.总是报错,如何解决?
  • ¥15 电脑买回,学校的有线网络总掉。
  • ¥20 关于普洛菲斯触摸屏与AB连接地址问题
  • ¥15 syri可视化不显示插入缺失
  • ¥30 运行软件卡死查看系统日志分析不出来
  • ¥15 C语言代码改正特征选择算法设计,贝叶斯决策,,设计分类器,远程操作代码修正一下
  • ¥15 String 类valuve指向的问题
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部