Error establishing a database connection

Just when you thought it was safe to check out your website and all you see is a white screen with big bold words that fill your heart with dread…..

The reason for this is exactly what it says on the tin, your website’s database connection has failed.

QUICK FIX

A quick and easy fix for this is to connect to your wordpress files through an FTP client like FireFTP or the similar and look at your wp-config.php

It will have a section of it looking like this.

MySQL settings

define(‘DB_NAME’, ‘database-name’);
define(‘DB_USER’, ‘database-username’);
define(‘DB_PASSWORD’, ‘database-password’);
define(‘DB_HOST’, ‘localhost’);

If the username and password are correct and your website is still down then your Database could be corrupt or your hosting server could be down.

You could try creating a new database user and filling in the details to your  wp-config.php file.

 

HOW TO DO THIS

Go to your cPanel and start up MySQL Databases

Once in here you’ll create a new user with a strong password

Next you add the user you just created to your websites database
(Consult the wp-config.php to find out the name of your database – DB_NAME’, ‘database-name‘)

Stick your new users username and password into the wp-config.php and using your FTP client load it back into your WordPress install.

Goodbye “Error establishing a database connection”