0
votes

I have a MySQL server running in RDS. I am able to connect to it when I'm running my website on localhost. But when I try to connect to myself through my website being hosted by the EC2 instance I can't connect. I tried looking through the security groups in the EC2 and it has as in inbound rule the following:

MYSQL/Aurora. TCP. 3306. 0.0.0.0/0

I'm sure the password, username, host, and database are correct because I can connect with them on localhost and through MySQL workbench.

I try to connect to mysql as follows:

$mysqli= mysqli_connect("blah.foo.us-west-2.rds.amazonaws.com:3306",'root','password', "innodb")or die($mysqli->error);
1

1 Answers

0
votes

You should connect it like

mysqli_connect("blah.foo.us-west-2.rds.amazonaws.com",'root','password',
"innodb",'3306')or die($mysqli->error);

Connection string look like mysqli_connect

mysqli_connect(host,username,password,dbname,port,socket);