我正在尝试将我的PHP应用程序连接到AWS rds。我已经完成了所有步骤,最后当我写这样的连接时:
$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() . ")");
}
我收到此错误: 数据库连接失败:没有这样的文件或目录(2002)
答案 0 :(得分:1)
首先创建一个允许公共IP到RDS实例的安全组。 检查您可以使用mysql命令行连接到RDS Db 然后
$con = mysqli_connect("yourAmazonEndPoint","UserName","Password","your_db");
check this for security groups
来自控制台:
mysql -h myinstance.123456789012.us-east-1.rds.amazonaws.com -P 3306 -u mymasteruser -p
或
mysql -h myinstance.123456789012.us-east-1.rds.amazonaws.com --ssl-ca=rds-ca-2015-root.pem