Sporadic wordpress database connection errors. What a troubleshot plan?

I have one WordPress website that has very sporadic db connection error "Error Establishing a database connection". What should I do to determine the root of problem, solve it and try to prevent it in future?

Brief story:
There is no pattern or something that could help me understand the nature of this problem.

Read More

Site many times was sporadically down for 30–40 seconds (according to Uptime Monitors) and after Up and running for another day. Few days ago it went down, and never come back. It just didn’t restore itself.

What I Did:
Digging around at /wp-admin/ WordPress said me that the database is broken. I tried to repair it by inbuilt WordPress’s tools. It did repair some of them, but couldn’t repair one table. I logged in phpMyAdmin and repaired it by inbuilt tools and site fortunately went back..

What might cause such outage?

I have to note that no any developments or changes were made to the site for many months. It is a restaurant site, it just lives on it own.

The is site hosted and managed (not by me) on a linux VPS. On that VPS sits MySQl, cPanel, ssd disks, DNS.

The issue haven’t touched the rest 10 WordPress websites. Only one particular.
Admin swears that on his side all is up and running. And puts pressure on me, that this is my fault as a web developer. And the site’s owner is looking for someone to blame on.

I tried to check error_log(in cPanel). but for some reason there is only last 10 lines. Don’t know why.

I have some meeting with admin and website owner to investigate this issue. Last outage was for about 3 hours on Friday evening. I presume owner have had lost some clients that day.

  • What an admin would advice me to look for?
  • What is the troubleshooting plan for such problems?
  • Is it something related to bots/spiders? Or some hackers trying to put down my site? Where can I check that?
  • Is there anywhere I could to dig MySQL logs out?

The point of this topic is to learn how to troubleshot such issues on my own. And also learn some preventive measures. Such outages not fun for clients, especially on Fridays.

EDIT:
Here is a log file for that day for those who is fancy enough to read them.(it’s huge!!)
https://www.dropbox.com/s/75xwop8m9qxrpo8/wordpress-error-establishing-database-connection_log

EDIT 2:
After checking for high spikes and hits (as suggested below by @aconrad) I found out that there was 40% higher rate of page views. But there is quite natural reason, the co–founder of the business was having a show on our local national TV. So that is the cause of additional 40% hits..
But I still believe 443 views per day is nothing.. and that still doesn’t explain why database table was broken.

EDIT 3:
I’ve got from admin MySQl log.. Is that helpful?
https://www.dropbox.com/s/t6yk8rtef1vpgig/MySql-Log-Wordpress-Database-Connection.err

Here is screenshot of a part of the log

Example of MySql Error log records

Related posts

Leave a Reply

3 comments

  1. You can check for bots/spiders by analyzing the traffic (see if there any spikes) and see access logs.

    To dig mysql you will need the slow query report (if enabled)
    http://dev.mysql.com/doc/refman/5.1/en/slow-query-log.html

    And then check if you can optimize the indicated queries.
    There are several tools that can generate a slow queries report using the logfile.

    If you site loads very slow to check if there is a problem with the database,
    run the query SHOW PROCESSLIST to see what exactly happends in mysql.

    If your tables are MyISAM, maybe this can help:
    http://dev.mysql.com/doc/refman/5.0/en/corrupted-myisam-tables.html

  2. http://relations-nations-unies.agence-presse.net

    Error establishing a database connection

    This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at ns322620.ip-37-187-155.eu. This could mean your host’s database server is down.

    Are you sure you have the correct username and password?
    Are you sure that you have typed the correct hostname?
    Are you sure that the database server is running?
    

    If you’re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.