dongzhong8691
2017-11-02 03:54
浏览 42
已采纳

无法将php应用程序连接到AWS rds实例

I am trying to connect my PHP application to AWS rds. I have done all the steps and finally when i write the connection like this:

$link = mysqli_connect($_SERVER['amazon-endpoint'], $_SERVER['myMasterUserName'], $_SERVER['myMasterUserPassword'], $_SERVER['ebdb'], $_SERVER['3306']);
if(mysqli_connect_errno()){
die("database connection failed: " . mysqli_connect_error() . " (" .
mysqli_connect_errno() . ")");
}

I get this error: database connection failed: No such file or directory (2002)

图片转代码服务由CSDN问答提供 功能建议

我正在尝试将我的PHP应用程序连接到AWS rds。 我已完成所有步骤,最后当我写这样的连接时:

  $ link = mysqli_connect($ _ SERVER ['amazon  -endpoint'],$ _SERVER ['myMasterUserName'],$ _SERVER ['myMasterUserPassword'],$ _SERVER ['ebdb'],$ _SERVER ['3306']); 
if(mysqli_connect_errno()){
die(“ 数据库连接失败:“。mysqli_connect_error()。”(“。
mysqli_connect_errno()。”)“); 
} 
   
 
 

我收到此错误:\ ndatabase连接失败:没有这样的文件或目录(2002)

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • drwu24647 2017-11-02 04:06
    已采纳

    First Create a security group which allows your public ip to RDS instance. The check you could connect to RDS Db using mysql command line Then

    $con = mysqli_connect("yourAmazonEndPoint","UserName","Password","your_db");
    

    check this for security groups

    from console :

    mysql -h myinstance.123456789012.us-east-1.rds.amazonaws.com -P 3306 -u mymasteruser -p
    

    or

    mysql -h myinstance.123456789012.us-east-1.rds.amazonaws.com --ssl-ca=rds-ca-2015-root.pem
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题