0
votes

I want to install Wordpress on an existing AWS ec2 instance. However, I get an error: "Error establishing database connection".

I followed the tutorial here:http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/hosting-wordpress.html

The only difference is that the tutorial is for people who are installing MySQL on the same ec2 instance while I wish to have MySQL run on a separate instance (ie: RDS).

The steps I carried out:

1) Installed the httpd24, php56 and php56-mysqlnd packages on the ec2 instance.

2) Created a MySQL user with privileges and db:

CREATE USER 'wordpress-user'@'localhost' IDENTIFIED BY 'your_strong_password';
GRANT ALL PRIVILEGES ON `wordpress-db`.* TO "wordpress-user"@"localhost";

3) Filled out the wp-config values with the appropriate values:

define('DB_USER', 'wordpress-user'); //without the "@'localhost'" part
define('DB_HOST', '[RDS endpoint]:3306');

4) The rest of the instructions outlined in the tutorial (allow permalinks and file permissions for Apache web server).

However, when I enter the url of the Wordpress blog I get the error: "Error establishing database connection".

Does anyone have any suggestions for what's wrong with my setup?

Thank you.

1
Two things do not use port number in wp-config and does your EC2 instance IP is whitelisted in RDS security group.error2007s
@error2007s you should whitelist the security group of the EC2 instance, not the IP address.Mark B
Hello, thank you for replying. Yes, the EC2 instance's security group is whitelisted in the RDS security group. This is how I set it up even before trying to install Wordpress. Any other suggestions? AWS support recreated the same error message by following the tutorial above...Maybe there's a reason why they don't provide a tutorial for my scenario? Maybe it's not meant to be done?theyuv
I got this working by not specifying a host for the DB user (ie: 'wordpress-user'@'%' rather than 'wordpress-user'@'localhost'). Is this safe? How come wordpress isn't accessing the DB via the localhost?theyuv

1 Answers

1
votes

I got this working by not specifying a host for the DB user (ie: 'wordpress-user'@'%' rather than 'wordpress-user'@'localhost').