Reputation: 121
I am trying to connect my AWS MYSQL DataBase, but I get this error.
Connection failed: SQLSTATE[HY000] [2002] Connection timed out
I've searched and notice it could a matter of security, adding the IP to the Security Group rules, but it still didn't work.
<?php
$servername = "****-1.cdvmnfrkbalc.us-east-2.rds.amazonaws.com";
$port = 3306;
$username = "admin";
$password = "******";
//$dbname = "phpmyadmin";
try {
$conn = new PDO("mysql:host=$servername:3306", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully.";
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
?>
How can I connect my DB to AWS?
Upvotes: 0
Views: 336
Reputation: 10724
To successfully connect to a MySQL RDS instance, you have to do 2 things:
Once you do these 2 tasks, you can connect. See this AWS tutorial on how we setup the RDS instance.
Creating the Amazon Relational Database Service item tracker
Upvotes: 2