简体   繁体   English

无法从Amazon EC2 ubuntu 16.04映像连接到Amazon RDS上的数据库

[英]Can't connect to a database on Amazon RDS from Amazon EC2 ubuntu 16.04 image

I have hosted a play framework web application on Amazon EC2 instance. 我已经在Amazon EC2实例上托管了一个play framework Web应用程序。 The application is not able to connect to a mysql database located on the Amazon RDS instance. 该应用程序无法连接到位于Amazon RDS实例上的mysql database When I run the play framework web application on my local computer it successfully connects to the database on the Amazon RDS instance. 当我在本地计算机上运行play framework Web应用程序时,它成功连接到Amazon RDS实例上的数据库。 I checked the database connection credentials in the production conf file many times. 我多次检查了生产conf文件中的数据库连接凭据。 Looks correct. 看起来正确。

When I do 当我做

mysql -h********.rds.amazonaws.com -p****** -u****** db_name

from the local computer it quickly connects. 从本地计算机快速连接。 But when I try same connection to RDS from EC2 it throws: 但是,当我尝试从EC2到RDS的相同连接时,它会抛出:

ERROR 2003 (HY000): Can't connect to MySQL server on ********.rds.amazonaws.com

Can anyone kindly help me with this or suggest anything that I may be possibly missing. 任何人都可以帮我这个忙,或者提出任何我可能会想不到的建议。

Is RDS in VPC? VPC中有RDS吗?

Yes, Check if EC2 is also in VPC or not. 是的,检查EC2是否也在VPC中。
No, Check security group that EC2 is in, allows the communication over database port 否,请检查EC2所在的安全组,是否允许通过数据库端口进行通信

For more info and scenarios, head here 有关更多信息和方案,请转到此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM