Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to create a wordpress blog on an Amazon EC2 instance. The amazon base image had apache and php already installed. I installed MySQL manually in my user directory. I am able to login to the MySQL database from linux command line. But I am not able to connect to the MySQL db from php. The scenario I tested was the following. I have a php file which I host through apache. When I open that php file in a browser; the MySQL connection fails. The following is the message in the browser

Error establishing a database connection

This either means that the username and password information in your wp-config.php file is incorrect or we can't contact the database server at xxx.xxx.compute-1.amazonaws.com:port. This could mean your host's database server is down.

    Are you sure you have the correct username and password?
    Are you sure that you have typed the correct hostname?
    Are you sure that the database server is running?

My question is. Is it incorrect to manually install MySQL when php has already been installed? I mean is it recommended to compile-install the php with mysql first?

EDIT

php/apache was already pre-installed in the machine which I instantiated from amazon. It has amazon linux as the OS.

rpm -qa |grep -i httpd
httpd-tools-2.2.16-1.0.amzn1.x86_64
httpd-2.2.16-1.0.amzn1.x86_64

rpm -qa |grep -i php
php-common-5.3.5-1.11.13.amzn1.x86_64
php-5.3.5-1.11.13.amzn1.x86_64
php-cli-5.3.5-1.11.13.amzn1.x86_64

Thanks. The yum install mysql-server helped a bit. So first I removed my manual installation; and then yum install mysql-server; Additionally yum install -y php php-mysql

EDIT 2

I debugged a bit more. What I found is that if I put the wordpress directory under apache root and don't do port forwarding (no Proxy and proxyreverse), then I am able to connect to the DB from the WP install files. However, if I put the WP files under JBoss and do port forwarding from apache to JBoss, then from within JBoss, I am unable to connect through WP php files to the MySQL DB. So the problem is somewhere within the Caucho Quercus part of JBoss. Any suggestions? Thanks

share|improve this question
    
How did you install PHP/Apache, What distribution of Linux? –  Devraj Jul 19 '11 at 1:44
    
php/apache was already pre-installed in the machine which I instantiated from amazon. It has amazon linux as the OS. –  rationalSpring Jul 19 '11 at 1:48
    
You should have just typed yum install mysql-server to install MySQL from Amazon's package repository. If it's working, though, it doesn't matter how you did it. If you can connect to the server with the mysql CLI, then so can your code once you figure out what mistake you made there. –  Dan Grossman Jul 19 '11 at 1:51
    
Better suited for Server Fault. –  Michael Mior Jul 19 '11 at 1:53
    
Is there a reason why you didn't want to just use Amazon's WordPress template for this? Just curious. –  Vid Luther Feb 10 '12 at 13:55
show 2 more comments

migrated from stackoverflow.com Jul 19 '11 at 12:18

This question came from our site for professional and enthusiast programmers.

closed as off topic by Chip Bennett, Rarst Feb 13 '12 at 14:22

Questions on WordPress Development Stack Exchange are expected to relate to WordPress within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

Try logging into the mysql instance from the command line by typing in mysql -u root -p and then entering your mysql root password. If you can connect, even if it rejects your username and password, you know it's up and running correctly.

From that point you can diagnose whether it is username/password issues or whether or not you need to properly configure mysql.ini

share|improve this answer
    
Thanks. I debugged a bit more. What I found is that if I put the wordpress directory under apache root and don't do port forwarding (no Proxy and proxyreverse), then I am able to connect to the DB from the WP install files. However, if I put the WP files under JBoss and do port forwarding from apache to JBoss, then from within JBoss, I am unable to connect through WP php files to the MySQL DB. So the problem is somewhere within the Caucho Quercus part of JBoss. Any suggestions? Thanks –  rationalSpring Jul 19 '11 at 4:25
add comment

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