I am on an Amazon ec2 instance and I have a database that I am trying to access via a PHP script. I am echoing out tests through the script so i seem to get to the end but I am not getting any errors. Whenever I change my localhost to my IP it says: Connection error: Can't connect to MySQL server on 'MY IP' (110). I have tried binding my localhost and server server IP to my.cnf file and still the same result. Are there any other configurations I am missing? I have never had this much trouble before but this is my first time working on an amazon ec2 Linux instance.
<?php
$con=mysqli_connect("localhost","root","password","database");
if (!$con)
{
die("Connection error: " . mysqli_connect_error());
}
echo "testing1";
$query = "SELECT id, email FROM user_key ORDER BY email DESC LIMIT 10;";
echo "here";
$result = mysql_query($query);
echo "here2";
while($row = mysql_fetch_assoc($result))
{
echo $row['id']." ";
echo $row['email']." ";
}
echo "last";
?>