Recently 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 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.
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.
Nice details about wordpress database error and mysql error.
ReplyDelete