WordPress “Error establishing a database connection”
July 13th, 2010 by oliver - hosting knowledge base web hosting wordpress wordpress troubleshooting
If you have the misfortune of experiencing the white screen of doom featuring the simple words “Error establishing a database connection” on your WordPress site, this post might help you troubleshoot.
The Simple Fix
Most people on the internet seemed to have this problem because their wp-config.php database info was incorrect. From the WordPress Forums:
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 localhost. 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?
If that’s indeed the problem then you’re in luck, just put the correct database name, database user name, and database password in that file. Make sure your database host is ‘localhost’ or figure out what is via your hosting company. Or hassle your hosting company to fix their mysql server. Here’s the part of wp-config.php you’ll want to change btw:
// ** MySQL settings ** //
define(‘DB_NAME’, ‘*****_wrdp1′); // The name of the database
define(‘DB_USER’, ‘*****_wrdp1′); // Your MySQL username
define(‘DB_PASSWORD’, ‘*****’); // …and password
define(‘DB_HOST’, ‘localhost’); // 99% chance you won’t need to change this value
The Hard Fix
Unfortunately this wasn’t my client’s problem. We are the hosting company and everything was working fine; her db user could connect and had the correct privileges, etc. After a little tracking down, it turned out that somehow the ‘siteurl’ option for her WordPress installation had been deleted. This value is also what resides in the “WordPress address (URL)” field under “Settings” on the backend. Note: don’t delete that.
I went into her database in phpmyadmin, found the table ‘wp_options’, and searched for ‘siteurl’ in the ‘option_name’ field. It was indeed empty so I entered her domain name- ‘http://’ and all- into the ‘option_value’ field. Viola.
Here’s the sql is you don’t roll GUI:
UPDATE ‘wp_options’ SET option_value=’http://yourdomain.com’ WHERE option_name=’siteurl’
2 Comments »
Additional comments powered by BackType
I think everything published was very logical.
But, what about this? suppose you typed a catchier post title?
I ain’t saying your content is not solid, however suppose you added a headline
that grabbed people’s attention? I mean WordPress ?Error
establishing a database connection? | The Present Group
Journal is a little boring. You could peek at Yahoo’s home page and watch how they create
article titles to grab viewers to click. You might add a video
or a related picture or two to grab readers interested about everything’ve written. Just my opinion, it could make your website a little livelier.
Some wordpress hijacks involve a script that changes the siteurl option. I wonder if this was a half-assed version of that.