2022-04-24
298
1 minutes.


MySQL server has gone away error



The MySQL Server Has Gone Away (error 2006) error can occur in a variety of ways.

Connection timeout

The most common problem is a connection timeout, causing the server to close it. The solution is quite simple - increase the time limit for the wait_timeout parameter in the my. cnf configuration file. To do this, on a Linux hosting server, you need to edit the MySQL configuration file:

/etc/my. cnf

Set the wait_timeout parameter to the number of seconds the server waits for activity on a non-interactive connection before closing it, up to 28800 s (8 hours).

[mysqld] . . . wait_timeout = 600 . . . 
[mysqld] . . . wait_timeout = 600 . . . 

Then restart the MySQL database server:

service mysql restart
service mysql restart

Large or invalid package

The second common problem is that the server receives a large or invalid packet and rejects it. In this case, the server thinks that the problem is on the client side and closes the connection. So for the solution, you need to increase the limit on the maximum package size, all in the same configuration file.

Increasing the incoming packet size limit, in MB

[mysqld] . . . max_allowed_packet = 256M …
[mysqld] . . . max_allowed_packet = 256M … 


Also don't forget to restart the database server.


Copywriter ElbuzGroup


Contents:



Save a link to this article