Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I've set up an EC2 instance it has mysql and php-mysql installed (not mysql-server).

I've set up an RDS instance and set the security group to the EC2 instance.

I can connect via the command line from the EC2, but when I try connecting via mysqli I get the message: Can't connect to MySQL server on 'XXXX.xxxxxxx.us-east-1.rds.amazonaws.com'

This is my first time working with both.

Am I missing something here?

define("HOST", "XXXX.xxxxxxx.us-east-1.rds.amazonaws.com");
define("DBUSER", "my_user");
define("PASS", "********");
define("DB", "mydb");
define("PORT", 3306);

$link=mysqli_connect(HOST,DBUSER,PASS,DB,PORT); 

// Check connection
if (mysqli_connect_errno($link)){
    echo "Failure to connect: " . mysqli_connect_error();
}

mysqli_close($link);
share|improve this question
    
What is the complete command you are entering at the shell prompt? –  jamieb Apr 1 '13 at 4:07
    
mysql -h XXXX.xxxxxxx.us-east-1.rds.amazonaws.com -P 3306 -u my_user -p –  jackreichert Apr 1 '13 at 4:13
    
You're not specifying a database in that command. Are you sure it's the entire command? –  jamieb Apr 1 '13 at 4:14
    
Yeah, it didn't connect to a specific DB but I WAS able to connect to the RDS server. However if I try the same via mysqli I'm getting "can't connect to server" –  jackreichert Apr 1 '13 at 4:17
    
Try connecting with the database. Your user probably hasn't been given specific permission to access that database. –  bahamat Apr 1 '13 at 6:22

1 Answer 1

up vote 0 down vote accepted

I found a similar issue.

The solution was to run setsebool -P httpd_can_network_connect=1

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.