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’