The common Error Maximum Bloggers face with their wordpress website is “Error establishing a database connection wordpress” Error , i too have faced the same issue any times, This Error Happens when our wordpress theme,plugin consumes more memory than our allocated memory in our server.
“Error establishing a database connection”, usually means one of two things:
1. Database server is down (not operating)
2. You have wrong information in your wp-config.php–either the DB_HOST, DB_USER, DB_PASSWORD, or DB_NAME is incorrect.
First thing you should always check is if everything in your wp-config.php file is the same.
The Below Options Must Be correct :
define('DB_NAME', 'database-name'); define('DB_USER', 'database-username'); define('DB_PASSWORD', 'database-password'); define('DB_HOST', 'localhost'); Remember your DB_Host value might not always be localhost. Depending on the host, it will be different.
If your Mysql is working fine , Removed Website URl or any options in Wp options :
Someone fixed the problem by logging into PHP My Admin
In your Database go to the table wp_options, When in here click browse, this lists all the information
You will notice the site URL value is blank.Click the edit button(looks like a pencil) and re input your URL into the Value text area and click save.Alternatively in the SQL Console add the following line. UPDATE YOUR DATABASE NAME.wp_options SET option_value = ‘http://YOURURL’ WHERE wp_options.option_id =2 LIMIT 1 ;ps: careful when copying the above line as the quotes may need to be re-entered
Solution 3 :
If you are Using a VPS, CLOUD or Dedicated Server , Just Restart Your Server , Mysql Will Start Working Fine. & your Website will get Online Within Seconds.
Solution 4 :
Check your Website Log File first & you will see some errors, long querys , Fix the issues.if it caused due to plugins delete the plugins , backup before that. Contact customer support of your hosting provider telling that your Mysql was stopped.
Solution 5 :
if the Problem occurs in wp admin panel then ?
1.Make sure that you are getting the same error on both the front-end of the site, and the back-end of the site (wp-admin). But, If you are getting a different error on the wp-admin for instance something like “One or more database tables are unavailable. The database may need to be repaired”, then you need to repair your database.
You can do this by adding the following line in your wp-config.php file:
Once you have done that, you can see the settings by visiting this page:http://www.example.com/wp-admin/maint/repair.php
Click on repair Database Option
Any Errors in Your Database will get fixed easily.
This is a Worst error. if you solve the error using above solutions,please post a comment. if you solved the issue with a new solution, describe in comments to help others.