(Last Updated On: July 31, 2021)

How to fix Error establishing a database connection in wordpress

 

If you are wordpress beginner, then this is a disgusting error message. Special thing is this error message happen without reason most of time. That mean this error message may be come suddenly. May be when you change your host severing. This error message also come one of our site. After 30min we could get that site online. After this and we also had some requests about asking this error message. So we researched about this and we realize there is no good post answering this question. So we thought to write this post to help who are searching answer for Error establishing a database connection in wordpress.

Note – We have a Video “Fix Error establish a database connection in wordpress”

 

Few emails had received, asking this matter.

 

“I tried to install WP on our local server and I got the ‘Error establishing a database connection’ screen. Can I know how to fix this my host is ipage”

“Why I am getting Error establish a database connection in wordpress. my host is HostGator”

” scene today morning i can’t access my site because  Error establish a database connection. my hosting site is godaddy 

 

Why Error Establishing a Database Connection screen appear to me

Because,  wordpress can’t establishing a database connection. Now you ask why wordpress can’t  J  My answer is, there are more reasons to happen this. most of time this happen when you change the host site. Unless It can happen when your data base is corrupted, after lot of sever errors, when Mysql data base server is unresponsive, when your logging details can’t match and when server that hosts your wordpress database is down

Note – before the any modification we advise you to get back up your data base and file manager

How do I solve Error establish a database connection in wordpress.

Go to your host site and go to file manager. Find the file named  “wp-config.php” and open it. (If you can’t open this file the download it and drag and drop to chrome new tab)

 Error establish a database connection

Check this things

 

Error Establishing a Database Connection

 

The name of the database for WordPress – this name must be match with Mysql data base name.

MySQL database username – User name must be match with Mysql DB user name.

 

MySQL database password – password must be matched with Mysql DB password
Note – If you can’t remember password then reset 

MySQL hostname– Hostname must be correct

 

After correct these, you can see Error establish a database connection is disappear in a moment.

If you can’t understand then watch Video tutorials about Error establish a database connection in wordpress

 

Not helped?

Open the “wp-config.php” and ad this code to that opened file. (If you can’t open this file the download it and drag and drop to chrome new tab)

define(‘WP_ALLOW_REPAIR’, true);

 

after adding  that code, you can see your site redirect to this link

http://www.yoursuperbwebsite.com/wp-admin/maint/repair.php     🙂 🙂 

Error Establishing a Database Connection

 

Click repair and optimize database

Note – after you ad that code, anyone (don’t need to logging to access this) can click the “repair and optimize database” So make sure to remove that code after you settle your site.

 

Not helped?  

Re-start the WordPress installation /reinstall wordpress

Not helped?

Then check your Hosting site whether it is work or not. If it is working then contact them. I’m sure they will help you

 

If you have any question or doubt please ask us J If you can ask with screenshot. We can also help you to with team viewer. (we can fix your problem through team viewer. If you help this post please share this over the social medias socially facebook and twitter and you had batter book mark us for future