Have you ever got an error establishing a database connection
what is database connection in wordpress
What does Error establishing a database connection mean?
whenever you try to acess the website php program tries to connect to the database and from there it loads the content you trying to access.
But, if you see something like error establishing a database connection it means
What Causes The”Error Establishing A Database Connection” Message to show in
there are actually several reasons to show these kinds of DB errors connect failed scenario they are :
1. Hosting Error from the hosting company
2. failed to connect to
3. User and password are not matching in wp-config.php file
4. Your themes or plugins are corrupted
5. All your WordPress files are corrupted
In such situations, you will be connected to
How to troubleshoot WordPress Error Establishing A Database Connection?
Here I am assuming that you are using WordPress CMS.We can solve that wordpress connection lost errors.
Fix 1: contact your hosting company to know if
error is from there end
This becomes the first step for you to take coz if those errors
So, my first suggestion would be, to contact your hosting provider from the live support section and let them know that you are facing some WordPress database error
Then they will let you know if its a problem from there end or it’s from your end.
Now after they fix the error try to access your site from the browser if still shows same error connecting to
then move to the second solution
fix 2:Check your database login details from wp-config.php
Another possible reason could be that your username and password may not be matching which you can easily fix from the wp-config.php
To fix this way you need to have your
How to know that
You need to see the initia l emails from your service provider they will give you the
otherwise, in some hosting, you can also access the
Now, I assume that you are in your
Now, after that I am gonna click on the file manager and i will enter into the Cpanel.After that I will get some screen like this:
now, double click on the left side : public_htmlAfter that find out wp-config.php
now you will see this
/** MySQL database username */ define('DB_USER', 'username'); /** MySQL database password */ define('DB_PASSWORD', 'password');
In this area, if the WordPress username and password are not being matched then it shows that error connecting to MySQL establishing
How to fix this password error ??
as shown in the figure to access the
How to access wordpress database?
Now, this time click on the MySQL Database:
After clicking on the database you will see the UI like this:
from here you can create new user and password
Take care of the username and password you put and generate here coz these are the one you put in wp-config.php
if you have created the new user then you need to activate that user by giving all the privileges,If you feel confused just change the password from same MySQl Database section . these options are just below the creating new user optionas shown in figure :
now again go to file manager from the client area
/** MySQL database username */ define('DB_USER', 'username'); /** MySQL database password */ define('DB_PASSWORD', 'password');and here replace the username and password
Now try to access the website from the browserIf you are able to access it then problem is solved.If not go to the 3rd solution
Fix 3: Check If You Can Still Access The WordPress Dashboard or not
So the now next solution is to see if you can access your wordpress dashboard or not.
remember this : wp dashboard login details and the database username and password are different.
At the time of installing wordpress you will have to choose username and password this is the same username and password that are used for logging in wp dashboard
at the time of accessing the dashboard if you see some error like this:
“The database may need to be repaired”
You need to repair your database now .
Step 1: mysql repair database (db)
To repair my sql database you need to again go the the same file manager as done in above scenario
Now, go to the public_html>>doubleclick it >> wp-config.php>> edit it
now after you click edit go to the bottom and add following code:
define( 'WP_ALLOW_REPAIR', true );
click on the save change
Step 2: Run the automatic database repair utility.
Now go to :
after this you will be able to run a tool which repairs your database
after this hopefully, your site should start working. What if didn’t work again?I have still 2 more options left.
Fix 4: fix to make sure Your Plugin or Theme Files aren’t Corrupted
This is the next step you can carry out to fix wordpress database
for this, again go to the file manager as in the previous steps
Now, go to the public_html>>click on + sign>>wp-content>>plugins
after going there you will see the plugins that are installed in your website.
sometimes those plugins and themes cause to happen error establishing a database connection in wordpress install time.
now as in the figure above you are seeing that the name of the plugin I have renamed from askmit to askmit_ replaced by (underscore )
Keep coming back to your site to see when the error gets triggered or vanishes. Once you’ve narrowed it down to one specific plugin, you have found the troublemaker.
Either delete it or go online to see if the solution has been found.
repeat same for the theme also .. change the themes to themes_
and try to check by going to the browser if it gets the db errors solved.
if it didn’t solve now rename back to the previous names.
Fix 5:Restore The Default WordPress Files
caution: before doing this take all the backups of your file: otherwse don’t blame me since this is the last option.
go to worpress officil site :
extract it ,
upload all the new files upload it from the
go to the file manager as previous and at the top, you will see the upload option upload the new and fresh version of your WordPress and try to see if it solves your problem or not.
let me show you what has worked for others :
after all you have paid them your hard earned money right if they are not fixing it it means they are not good hosting providers,
who knows what other problem you may get in future so choose another best hosting as fast as possible.
One last word : Are you a bloggers ? subscribe to this blog and lets grow together .
If this helped you why not to share with other show your followers that you care of them by sharing the content they may love ; sharing is caring
Other articles to read for you: