I know there are other similar questions on the site, but I haven't been able to find a solution.
I have an RDS instance set up. We run our site on an EC2 instance.
I know MySQL
works on the EC2 instance, because our current MySQL
database is run on a different non-RDS server, and everything works fine.
I can connect to the RDS instance through MySQL
workbench (I've approved my public IP address to connect).
I can connect to the RDS instance via phpMyAdmin
, which is installed on the EC2 server.
However, I cannot connect to the RDS instance using PHP/MySQLi.
DEFINE ('DB_USER', '**user**');
DEFINE ('DB_PASSWORD', '**pass**');
DEFINE ('DB_HOST', '*************.rds.amazonaws.com');
if($dbc = @mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD)){
//DB connected, do nothing
}
else {
echo 'Connection error';
echo mysqli_error();
exit();
}
I'm getting no error output, nothing. It just echoes "Connection error".
I have the EC2 instance and RDS sharing a security group (although I can only edit inbound rules, not outbound, is this weird?), and have the EC2's public elastic IP allowed on the RDS security settings.
I'm lost!