The other day I was playing around with my wordpress MySQL install on an Ubuntu 9.10 server. It didn’t take long before the only thing showing up in my browser was “Error Establishing a Database Connection”. Damn I had managed to mess up WordPress and it’s sweet 5 min no hassel install. Everyplace I’d looked for help told me to review the settings in my wp-config.php file. …and since it was my server, my wordpress, and my mySQL, I could only blame the A-hole who messed it up. Me.
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘wp_wordpress’);/** MySQL database username */
define(‘DB_USER’, ‘wp_wpuser’);/** MySQL database password */
define(‘DB_PASSWORD’, ‘asdfwghkjl’);/** MySQL hostname */
define(‘DB_HOST’, ‘localhost’);
I checked all the settings above repeatedly and they seemed to be correct. I created and destroyed users in myPHPadmin over and over again with no luck.
Now here’s the weird part. If I went to the admin side of Wordpress “/wp-admin” it would load and present me a login.. weirder still.. if I logged in as admin it would let me view the blog as if nothing was wrong. Ok..ok.. this is not a database issue or connectivity I thought. I remembered during the initial setup of the blog when I was trying to update plugins it would display the FTP crentials page which I had learned in the past was a file system ownership issue. To rememdy this I gave ownership of the wordpress files to the Apache2 process user name “www-data”. To find the username associated with your servers apache process try “ps aux | grep apache” the first column should be what you’re looking for.
sudo chown -R www-data:users <your WP-DIR>
So I thought it’s worth a shot to give it a try again… viola! it worked. WordPress came right up. No more “Error Establishing a Database Connection”. 🙂