Skip to content
Advertisement

WordPress database error MySQL server has gone away for query

I get this error so frequently that the php_error log file increases 1MB every 2 seconds. and the site is very slow.

I have tried to add this line to wp-db.php

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

but it did not help.

The web server is IIS 7, latest version of mysql and wordpress

Advertisement

Answer

This trick will work for all WordPress versions. Open your WordPress directory. The directory will contain the folders :

wp-admin
wp-content
wp-includes

Open wp-includes. Search for the wp-db.php file. If you found the file, open it using a text editor. Using the text editor’s search tool, search for :

$this->ready = true;

Once you found the line, add the following lines just after the found line :

//WP Query Gone Away Error Fix
$this->query("set session wait_timeout=600");

You can also follow https://subinsb.com/fix-wordpress-error-mysql-server-has-gone-away link to view in more detials.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement