How to fix, Error establishing a database connection in wordpress?

Sometime you may able to see the error message in your wordpress site that is ‘Error establishing a database connection’. If you are so lucky, then you will be see that, you can not access your wp-admin part due to the same reason. If you have experienced on it, definitely you are luck wp developer.  Anyways, lets see how to fix that kind of issues.

Wordpress Database connection error fix

Well, now first thing you have to do, log in your site via cpanel or ftp accounts. I am pretty sure that you have a that kinds of access authority if you are a real developer.

For CPanel:

Go to wordpress site directory (www.mysite.com). After that, open wp-includes/wp-config.php file by code editor. Try to find out the following codes-

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

You will be able to see that your wordpress site database username and password. You have to change it now. But before that, you have to options to fix this problem. Either you can use your cpanel username and password or you can fix the DB_USER and DB_PASSWORD from your cpanel.  Save it and refresh your site. Perhaps, it is working.

 

For FTP Account:

After successfully login by your FTP account,  download wp-includes/wp-config.php file and open in your computer by  code editor. Try to find out the following codes-

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

You will be able to see that your wordpress site database username and password. You have to change it now. But before that, you have to options to fix this problem. Either you can use your cpanel username and password or you can fix the DB_USER and DB_PASSWORD from your cpanel.  Save it and refresh your site. Perhaps, it is working.

Hope you enjoyed it. Thanks for reading and see you by next tutorials. 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s