• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » Fix Sudden Error Establishing a Database Connection WordPress

By Abhishek Ghosh April 6, 2014 10:37 pm Updated on April 6, 2014

Fix Sudden Error Establishing a Database Connection WordPress

Advertisement

Fix Sudden Error Establishing a Database Connection in WordPress By Following Our Logical Flow Chart Without Taking Much Sudden Headache. Causes of Sudden Headaches are not really great ! We are talking about fixing the typical appearance of white page declaring Error Establishing a Database Connection in WordPress all of a sudden in a five minutes ago working great website. This is not for those who could never establish a Database Connection or getting MySQL Gone Away Error. Many years ago we published an article – Tips to Optimize WordPress Running on Dedicated Server, although with time; the links or tips are not fully applicable now anymore but actually the basic issue is with resource allocation to MySQL database.

 

Error Establishing a Database Connection WordPress : For Those Who Has No Idea About Technical Parts

 

Those who has no idea about SQL, MySQL, PHPMyAdmin or what type of web hosting you are using, it is better to take someone other’s help. Usually your web hosting company’s support will work fine. Do not try to experiment on trial and error basis.

 

Fix Sudden Error Establishing a Database Connection WordPress

 

This typical error usually appears when working on your site or making some changes and sometimes side by side published a new post; suddenly you see the dreaded white page with the error message “Error Establishing a Database Connection”. Usually it happens with One Server running both MySQL Server and Apache2 / Ngnix Web Server Software. It is rare for 2 or multiple server setup. If you are using a server without a web hosting control panel (like Rackspace Cloud Server, Amazon or MediaTemplate’s high end servers), the fix is usually to SSH as root and simply restart MySQL server :

Advertisement

---

Vim
1
sudo /etc/init.d/mysql restart

Then restart Apache or perform a full reboot :

Vim
1
2
3
4
# restart apache
/etc/init.d/apache2 restart
# reboot
reboot

Usually error will go away. Reasons can be many, but usually it happens due to buggy plugins.
If the situation is to bad and a reboot does not solve, open your wp-config.php file and add at the bottom :

Vim
1
define('WP_ALLOW_REPAIR', true);

If you point your browser towards your website’s this url :

Vim
1
http://www.yoursite.com/wp-admin/maint/repair.php

you will be able to repair the corrupted database. It is important to double check the database details (unlikely they will be wrong – since 5 minutes ago they were working nicely). Sometime’s with wrong chmod value, deactivating W3 Total Cache like plugin can make the whole wp-config.php white – instead of deleting one single line, it fully deletes all the lines. This is why we suggest to change the ownership of wp-config.php to root instead of giving it to Apache (www-data) and chmod it to as low value as possible so that no Plugin can overwrite it.

Actually you need to optimize your WordPress installation and most importantly, tweak MySQL Server to perform better. If you have recently migrated, you can try to run this SQL command (edit the statements, url etc.) :

Vim
1
UPDATE YOUR DATABASE NAME.wp_options SET option_value = 'http://YOURURL' WHERE wp_options.option_id =2 LIMIT 1 ;

Fix Sudden Error Establishing a Database Connection WordPress

Plesk, cPanel, Webmin etc. web software usually will run normally (if installed), so as Apache, PHP.
Plesk, cPanel, Webmin are more related to Perl than MySQL. GoDaddy, Bluehost etc. shared, VPS face these errors due to inadequate allocated resource. Try to upgrade to better web host which are standard now like Rackspace, Amazon, HP Cloud etc. It is not that, you’ll never get Sudden Error Establishing a Database Connection on these hosts, but actually you can allocate more resource to MySQL server or use a Database as a Service. Primarily it happens out of a protective mechanism to prevent destruction of the data saved on database. With sudden spike of increased need of RAM for MySQL (just to make it simple), MySQL Server stops to execute anything.
Once you saw it, use some web software to monitor up time and ping you when the server is not working properly. Not all service will give alert for MySQL errors.

Tagged With error establishing a database connection , error connecting database , mysql gone error , cant establish database connection , error establishing a database connection sudden , error establishing a ms sql server database connection wp-config php , How to Fix the Error Establishing a Database Connection in WordPress
Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Fix Sudden Error Establishing a Database Connection WordPress

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • Fix WordPress Error in Database Connection : MySQL Part

    MySQL Setup & Corrupted Database Has to Do With the Error Establishing a Database Connection. Fix WordPress Error in Database Connection.

  • WordPress & PHP : Different AdSense Units on Mobile Devices

    Here is How To Serve Different AdSense Units on Mobile Devices on WordPress With PHP. WordPress Has Function Which Can Be Used In Free Way.

  • How to Install WordPress : Ubuntu 16.04, Nginx, PHP7-FPM

    Here is Step by Step Guide on How to Install WordPress on Ubuntu 16.04, Nginx, PHP7-FPM, memcached & Percona MySQL 5.7 on Cloud Server or VPS.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • PowerAmp Settings for Higher Sound QualityOctober 4, 2023
  • Affordable Earphone/IEM for Audiophiles: HiFiMan RE-400 WaterlineOctober 2, 2023
  • What is Hardware Security Module (HSM)September 30, 2023
  • Transducer Technologies of HeadphonesSeptember 28, 2023
  • What is Analog-to-Digital Converter (ADC)September 27, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy