Searching for something ?

Chetan
  • home
  • About
  • Contact
  • Categories »
    • Blogging
    • Images
    • Internet
    • Mobile
    • My Computer
    • Personal
    • Programming
    • Throughout
  • Wordpress Plugins »
    • WP-CopyProtect
    • Smooth Scroll
  • Add to Google

Blogging

WordPress database error MySQL server has gone away for query in WordPress 2.7

13.12.08 | 9 Responses | By Chetan Gole.
ADS BY GOOGLE

ico_wp_databaseRecently i optimize my WordPress for performance with many tweaks like deleting useless tables from database. Installed WP-Super cache, etc.
I was checking the error_log file in my Filemanager i was shocked due to its size, it was 14MB large !. I download it and opened it, all the errors were related to Database.
Almost all lines were starting with
“WordPress database error MySQL server has gone away for query…..”
and few were like this
“WordPress database error Lost connection to MySQL server during query for query…..”

As per the Error statement, the error clearly notifies that the connection between the WordPress and MySQL database was not proper. I just searched Google and seen many results, then i got the idea that its a General problem for many wordpress users.

Rob given a solution for this problem with few patched files to be replaced, You can read his article “Workaround for WordPress database error“. The article give detailed information about this problem. He also given files to be replaced to solve this problem.

According to him, This error is cause due to improper coordination between database and WordPress PHP commands.

According to Rob ,

When someone tries to view one of your WordPress web pages, the PHP code first opens a connection to the MySQL server. Subsequent queries to the MySQL server rely on the connection remaining open, and do not re-open the connection. If the connection to the server happened to have shut down before a query is made, then WordPress will display this error.

So for that you need to change the value of “wait_timeout” variable, either ask your site hosting admin to do it for your else you can do it by your self by tweaking your wordpress file named wp-db.php.

Rob given replacement files for WordPress upto version 2.6.1 but recently WordPress 2.7 is released so how to do the patch for WordPress 2.7 ?

Here i am including the file to be replaced by original “wp-db.php” file for WordPress 2.7.

Original wp-db.php
Workaround wp-db.php

Make sure you Backup your database and other files.

In above Workaround file, i just added

$this->query("set session wait_timeout=600");

in line number 334 in original file.

So do Check your Error log file today, else this may cause increase in your site loading time.

  • Email

Ads by Google

Possibly similar posts

  • TheChetan.com shifted their servers to hostgator :)
  • How to install WordPress locally on Windows PC to test.
  • Comment pages in WordPress 2.7 and SEO.

9 Comments

  • Nihar said:
    Dec 16, 2008 at 2:53 pm

    I have encountered this. i WILL TRY THIS SOLUTION OUT.

    Reply to this comment

  • Salwa said:
    Dec 22, 2008 at 6:16 pm

    I have never encountered this before but thanks for the information. It is always good to “know”

    Reply to this comment

  • cwxwwwxwwxwx said:
    Dec 24, 2008 at 1:07 am

    well, hi admin adn people nice forum indeed. how’s life? hope it’s introduce branch ;)

    Reply to this comment

  • Tom Aquinas said:
    Jan 5, 2009 at 5:54 am

    Thanks for the help!

    Reply to this comment

  • Slim0123 said:
    Feb 8, 2009 at 12:00 pm

    But why would a query take that much time??
    I don’t think this happens except for the case that you are installing something new(it took longer only when I tried to install 60 plugins at the same time)
    There must be something else taking time (may be some backup plugin or something like that).

    Reply to this comment

  • PiterKokoniz said:
    Apr 8, 2009 at 8:42 am

    Hi !! ;)
    My name is Piter Kokoniz. oOnly want to tell, that I’v found your blog very interesting
    And want to ask you: what was the reasson for you to start this blog?
    Sorry for my bad english:)
    Thank you:)
    Your Piter Kokoniz, from Latvia

    Reply to this comment

  • Vikas said:
    Aug 11, 2009 at 10:55 am

    I had changed the wp-db.php file but the same error occurs when i reply to any post,

    If you have any solution regarding this please send.

    Thanks in advance

    Reply to this comment

  • bJones said:
    Jul 9, 2010 at 8:55 pm

    Or you could just set the variable in your my.cnf file on your database setup. This would make it so the solution would good even when you upgrade. Why make it harder then it is….

    Reply to this comment

Trackbacks

  • • TheChetan.com shifted there servers to hostgator | TheChetan.com

speak up

Add your comment below,

Be nice. Keep it clean. Stay on topic. No spam.

* Required Fields

Cancel

  • « Mumbai Terrorist Attack – Now whats the future of TAJ and Oberai ?
  • » Hit George Bush with shoe – The Flash Game

Subscribe for updates

Subscribe to RSS Feeds RSS updated or Subscribe via E-mail.

About auther

Chetan GoleChetan Gole is web enthusiast and blogger who loves all things design and technology. He is a Software Engineer by profession. Blogger, photographer, techie by hobby. Find him online on Facebook, Google+, Twitter. read more...

recent posts

  • Search : Italian Bar Girl in India.
  • Installing Hindi, Marathi devanagari Unicode Fonts on Android mobile.
  • HTTPS / SSL – What is it ? Why it’s so Important ?
  • Mozilla Firefox 4 Launch party – Nagpur – India
  • MTV Roadies – The truth ! (Fake, Scripted, etc etc)
  • Sound Beyond Size – X-Mini Capsule Speakers review.
  • Ways to check BSNL Broadband (Dataone) internet usage
  • Ads




    This space is available for

    Advertisement





  • Twitter updates

  • Ads

  • Topics

    Airtel Best Browser blogging Broadband Browser BSNL Dataone Download Firefox Free Freebie Free DVD Funny Gmail Google hacks Images India Internet Internet Explorer Linux Microsoft Mobile Mozilla My Computer Nagpur Nokia OpenSource Pagerank Programming Security SEO Server SMS Sony Ericsson speed Stickers Sun Tricks and Tips Ubuntu uTorrent Webmaster Windows wordpress world
Top ↑
Creative Commons License All trademarks mentioned on this page are the property of their respective owners.Content distributed under CC Licenses Attribution-SA 2.5.
Please read Privacy Policy and Disclaimer. Powered by Wordpress and hosted at HostGator. You can contact me for any communication.
loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.