问题
I'm using AWS for my project and Laravel 5. Just installed my laravel project in the EC2 and set up a DB in RDS. I imported the .sql
file using mysql workbench. In my .env
I set up the host, the DB name, user and password but when I go to the project in the browser I get an error:
PDOException in Connector.php line 55:
SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'blue*****.************.us-west-2.rds.amazonaws.com' (4)
Put the *
for security reasons. So what could be wrong?
Update:
When I tried to connect to the RDS instance using the command line I got:
ERROR 2003 (HY000): Can't connect to MySQL server on 'blue****.**********.us-west-2.rds.amazonaws.com' (110)
回答1:
The reason you are not able to connect to the RDS instance from the EC2 instance has to do with security group.
Before your EC2 instance can communicate with the RDS server, you need to configure a security group for the RDS.
You can check this and this for more details.
来源:https://stackoverflow.com/questions/35840504/cant-connect-a-db-to-aws