MySQL general error – 2006 MySQL server has gone away
Does this error message scare you ?
SQLSTATE[HY000]: General error: 2006 MySQL server has gone away
Today we will take a look at it and find ways to deal with it ๐ . after investigating the issue and google it online, i founded two most common reasons (and fixes) for the MySQL server has gone away (error 2006) are:
1.Server timed out and closed the connection. How to fix: check that wait_timeout variable in your mysqldโs my.cnf/my.ini configuration file is large enough.
- On Linux: sudo nano /etc/mysql/my.cnf, set wait_timeout = 600 seconds (you can tweak/decrease this value when error 2006 is gone), then sudo /etc/init.d/mysql restart. The default value for wait_timeout might be around 28800 seconds (8 hours).
- On Windows: open /path-to-mysql-installation/bin/my.ini, set wait_timeout = 600 seconds (you can tweak/decrease this value when error 2006 is gone), then restart mysql server. The default value for wait_timeout might be around 28800 seconds (8 hours).
2.Server dropped an incorrect or too large packet. If mysqld gets a packet that is too large or incorrect, it assumes that something has gone wrong with the client and closes the connection. You can increase the maximal packet size limit by increasing the value of max_allowed_packet in my.cnf/my.ini file.
- On Linux: sudo nano /etc/mysql/my.cnf, set max_allowed_packet = 64M (you can tweak/decrease this value when error 2006 is gone), then sudo /etc/init.d/mysql restart.
- On Windows: open /path-to-mysql-installation/bin/my.ini, set max_allowed_packet = 64M (you can tweak/decrease this value when error 2006 is gone), then restart mysql server.
1 Comment