-1

These are my inbound rules of security group

I have setup phpmyadmin on EC2 ubuntu instance. Here is the link: http://ec2-54-191-119-142.us-west-2.compute.amazonaws.com/phpmyadmin

But I am not able to access it from my php file from my laptop.

<?php

$hostname = "ec2-54-191-119-142.us-west-2.compute.amazonaws.com:3306"; //database host server
$database = "fyp_data"; //database name
$username = "root"; //database user
$password = "*********"; //password

$con=mysql_connect($hostname,$username,$password);
if(! $con)
{
die('Connection Failed'.mysql_error());
}
else
echo "hurray!";
?>

Here is the error : "A connection attempt failed because the connected party did not properly respond after a period of time or established connection failed because connected host has failed to respond"

I have tried everything. Thanks in advance!

Hussnain Cheema
  • 152
  • 5
  • 15

1 Answers1

1

Make sure that port 3306 in your EC2 security group (inbound) is set to your home/office ip else the EC2 will just block your connection.

More info about how to setup the security group can be found here: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html#adding-security-group-rule

Daan
  • 11
  • 2
  • I have added multiple rules in my security group. 80 tcp 0.0.0.0/0 ✔ All All 0.0.0.0/0 ✔ 22 tcp 0.0.0.0/0 ✔ 5901 tcp 0.0.0.0/0 ✔ 3306 tcp 0.0.0.0/0 ✔ 3389 tcp 0.0.0.0/0 ✔ 443 tcp 0.0.0.0/0 ✔ – Hussnain Cheema Apr 16 '16 at 17:54
  • Please see this http://stackoverflow.com/questions/9766014/connect-to-mysql-on-amazon-ec2-from-a-remote-server it seems to be the exact same problem you're having. – Daan Apr 16 '16 at 18:50