08.21.2019

Cannot connect EC2 to RDS via PHP but command line

I cannot connect RDS from EC2 using phpMyAdmin but I can connect by command line. 

When I connect RDS via PHP (phpMyAdmin) an error was occurred.

mysqli_real_connect(): (HY000/2002): Permission denied

Steps I had did.
- Need check on security group that allow 3306 or not.
- Check EC2 and RDS zone if you are not allow to connect RDS from public access
If everything done but error still occur.
Just run below command to solve.

setsebool -P httpd_can_network_connect=1

Now I can connect RDS from EC2.
Hope it may help someone in same situition.
 

Leave a comment