• 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 WordPress Error in Database Connection : MySQL Part

By Abhishek Ghosh October 27, 2015 8:49 am Updated on October 27, 2015

Fix WordPress Error in Database Connection : MySQL Part

Advertisement

MySQL Setup & Corrupted Database Has to Do With the Error Establishing a Database Connection. All know – restarting MySQL from SSH fixes the issue instantly in majority of the cases! We Will Fix WordPress Error in Database Connection in this Guide Alongwith Basic Error Log Analysis. For whom this article is intended? Advanced users or who are learning to become advanced users. This guide is for dedicated server, cloud server instance, traditional VPS etc. but not for Shared Hosting. It is meaningless to pay $15/month for a Shared Hosting when at $10/month one can get one 01 GB cloud server instance.

We expect that, the user is using Percona or MySQL or MariaDB and know how to do SSH!

Error Establishing a Database Connection is more common in DigitalOcean, Linode etc. over HP Cloud, Rackspace Cloud with everything being the same. We do not know the reason. We guess, these are related to network card or router working behind – minor issue get magnified. Rackspace Cloud cost huge for the tuning works at backend!

Advertisement

---

 

Fix WordPress Error in Database Connection : MySQL Part

 

WordPress database is quite pathetic in real life. If you have ever used Apache2 (you means your database) and now using Nginx, there is enough chance of getting Error Establishing a Database Connection message. First divine work is to eliminate the chance of corrupted database, it may not be so easy as we wrote here – Fix Sudden Error Establishing a Database Connection.

Above hyperlinked way is an easy method, just add :

Vim
1
define('WP_ALLOW_REPAIR', true);

in /wp-config.php file and visit https://this_is_your_site.com/wp-admin/maint/repair.php on browser and follow the web instruction. Automatic system. Wait! Read ahead. Yes, very risky without a database backup. Easy to take a backup from SSH :

Vim
1
mysqldump -h localhost -u root -p you_wp_db_name > wpbackup.sql

I will suggest to create a database beforehand :

Vim
1
2
3
CREATE DATABASE backupwp;
use backupwp;
\. wpbackup.sql

With that last line, from dump, database will be created. Few minutes matter. So, your backup database username is root with your password, database name is backupwp. Live working backup of database. Now run that database repair of WordPress. If sky breaks on the head, change credential in /wp-config.php file to that backup’s one. Simple.

Fix WordPress Error in Database Connection - MySQL Part

 

Fix WordPress Error in Database Connection : mysql_safe is Idiot

 

mysqld is odd. Run mysqld --verbose --help in SSH screen. MySQL should never die in that way throwing an abnormal error. MySQL Safe actually kept as failsafe way to not die :

Vim
1
https://dev.mysql.com/doc/mysql-startstop-excerpt/5.5/en/mysqld-safe.html

Basically, by default, at my.cnf under [mysqld_safe], all needed are not present, socket, PID if not present, probably mysqld can not restart on crash (I am not MySQL database expert) :

Vim
1
2
3
4
5
6
[mysqld_safe]
pid-file        = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
nice = 0
log_error=/var/log/mysqld.log
datadir=/var/lib/mysql

In real life – you really never need an external script to restart MySQL. Yeah, the above thing kill keep MySQL server up but, it may still die at some action when you’ll perform. It is unlikely to fail to restart on a well tuned my.cnf.

 

Fix WordPress Error in Database Connection : Never Use Script, Software to Restart MySQL on Failure

 

People uses monit to auto restart MySQL on failure but without reading software engineering, I can definitely say – that Indian bloggers promoted monit to auto restart MySQL on failure is wrong approach. MySQL is very powerful software. Upon any sort of attack on MySQL, it is better if gets shut down. Do not do idiotic works. Log files are not for decoration. This is a very basic log analysis followed by fix. Our servers never need such “auto restart mysql on crush script”? Billions of WordPress are running on this Earth without such idiotic methods. If some error of MySQL can not be fixed by you, you need a good MySQL expert. Do not find a cheap Indian “MySQL Expert”. Good person around MySQL will charge the same all around the World.

Tap that /var/log/mysqld.log :

Vim
1
cat /var/log/mysqld.log

Here is an example of error with huge output.

In the log, there is clear history of crushes :

Vim
1
2
2015-10-27 08:10:16 7841 [Note] Starting crash recovery...
2015-10-27 08:10:16 7841 [Note] Crash recovery finished.

As you can see, for that database, there are errors which are clearly possible to fix. WordPress database need fix :

Vim
1
Unsafe statement written to the binary log using statement format since BINLOG_FORMAT

Another one in combination :

Vim
1
Too many connections

Everyone knows to fix – run locate my.cnf and find the path of my.cnf and open that with a text editor :

Vim
1
nano /etc/mysql/my.cnf

search for max_connections and increase the value. Gracefully restart mysql (service mysql restart for Ubuntu). If you get :

Vim
1
2
* Stopping MySQL (Percona Server) mysqld                                [ OK ]
* Starting MySQL (Percona Server) database server mysqld                [fail]

that means, max_connections value was edited to too high. Lower it & gracefully restart mysql. After solving all the problems, empty the log file :

Vim
1
echo " " > /var/log/mysqld.log

Tagged With error establishing a database connection digitalocean , mariadb regular Error establishing a database connection

This Article Has Been Shared 299 Times!

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 WordPress Error in Database Connection : MySQL Part

  • Adding Schema.org Structured Data in Genesis Theme

    Adding Schema.org Structured Data in Genesis Theme without using any plugin is quite easy as Genesis has great documentation and has excellent existing markups.

  • WordPress Post to Downloadable PDF, Text : Practical Options

    WordPress Post to downloadable PDF, Text has many points to consider when we will think about the usability, SEO, HTML5 and Schema.org markups.

  • Remove WordPress Plugin From Database Video Guide

    Remove WordPress Plugin From Database Video Guide shows how to delete tables, rows from MySQL database for plugins previously installed and uninstalled later.

  • Outgoing Link Tracking with Google Analytics

    Outgoing Link Tracking with Google Analytics is quite easy to setup both with the traditional or the asynchronous code. You can track outgoing certain link.

  • Remove wp-emoji-release.min.js Loading From WordPress

    This new javascript of emoji is added in WordPress 4.2 which force loading wp-emoji-release.min.js at front end. Here is how to easily remove.

Additionally, 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

  • What Online Casinos Have No Deposit Bonus in Australia March 30, 2023
  • Four Foolproof Tips To Never Run Out Of Blog Ideas For Your Website March 28, 2023
  • The Interactive Entertainment Serving as a Tech Proving Ground March 28, 2023
  • Is it Good to Run Apache Web server and MySQL Database on Separate Cloud Servers? March 27, 2023
  • Advantages of Cloud Server Over Dedicated Server for Hosting WordPress March 26, 2023

About This Article

Cite this article as: Abhishek Ghosh, "Fix WordPress Error in Database Connection : MySQL Part," in The Customize Windows, October 27, 2015, March 31, 2023, https://thecustomizewindows.com/2015/10/fix-wordpress-error-in-database-connection-mysql-part/.

Source:The Customize Windows, JiMA.in

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

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT