I have been at this for days trying to get this to work. I just followed the AWS tutorial and installed a LAMP stack on an EC2 instance of AMAZON LINUX. I have been trying to just do basic connections to it. Just easy Insert statements and I continually get this error:
The server is working.. i have a test file that works.
My database is set up and ready. It will receive an id, a username, a password, and an email address. But I cannot connect to mysql. I have: 1) set up a user and granted all privelages 2) checked the my.cnf file. There is no "bind-address" listed to change, but I added one in just to check. I added my server IP. Still did not work. 3) Security groups are wide open. I have SSH, HTTP, HTTPS, and MySQL accepting inbound connects from "Anywhere".
Here is the simple task I'm trying to accomplish:
<?php
$servername = "xx.xx.xxx.xx;
$username = "ec2-user";
$password = "112233445566";
$dbname = "db";
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO MyGuests (id, firstname, lastname, email) VALUES(1, Fake, User, fake3mail@gmail.com);
if ($conn->query($sql) === TRUE) {
echo "Table MyGuests created successfully";
} else {
echo "Error creating table: " . $conn->error;
}
$conn->close();
?>
Task I'm trying to accomplish: connect to MySQL database and insert a row of data.
Actual result: Error and the inability to connect.
I have scoured the internet for DAYS now trying to get this to work. What the heck am I missing here?! Are there even more configurations that must be done? I have tried every single thing that I've read and it does not work .