When trying to connect to my database server, i encounter the problem of unknown host:
Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2005):
Please pay attention with AWS security groups:
In my case I can connect to RDS from my computer throw Telnet and I can connect throw Mysql Workbench also but I cant connect from my EC2 instance that is within the same VPC as the RDS.
The solution was:
1. I have created a security group (exampl1) for RDS and assigned to it.
2. I have created a security group (exampl2) for EC2 and assigned to it.
and I have assigned the RDS security group (exampl1) to the EC2 too. << this saves me.
Info: If your EC2 has assigned 2 or more security groups, then in the RDS security group inbound source has to create rules as many security groups has your EC2 assigned.
Amazon docs says:
The EC2 instance in the VPC shares the same VPC security group with the DB instance. http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.RDSSecurityGroups.html
I spent all day searching docs.
I hope this help you.