abhishek kumar

August 5th, 2008 at 2:09 am

MySql server has gone away, database error in WordPress

mysql_error.jpgSome of my readers complained me that while browsing abhisays, they got a database error saying “MySql server has gone away on line 122″. I also tried the scenario suggested my by readers but I am still unable to reproduce the defect. I searched on Google for this WordPress defect, then I found that there are several possible causes to getting this error. Rob explains the error in his blog post.

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. One reason that the connection may shut down is if it has been idle for “wait_timeout” seconds since the last access to the connection. “wait_timeout” is a system variable in your MySQL server configuration.

Rob has created a tool to allow you to check the value of “wait_timeout”. However Rob has made changes to wp-db.php so that you will never get this error again. Just download the fix from Rob’s blog and replace the original wp-db.php with the new one. The file is located at wp-includes/wp-db.php (just overwrite the existing file).

Thanks Rob for such a nice solution.

==> If you liked this post, then why not buy me a beer so I can cool off?


Enter your email address:

1
  • 1

    Thanks for finding the fix. It worked for me!

    Navjot Singh on August 27th, 2008

 

RSS feed for comments on this post | TrackBack URI

Close
E-mail It