The MySQL server has gone away (error 2006) has two main causes and solutions:
- Server timed out and closed the connection. To fix, check that
wait_timeout
mysql variable in your my.cnf configuration file is large enough. - 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. To fix, you can increase the packet size limit .
Mysql command:
Use this command for ncrease the packet size limit .
set global max_allowed_packet=104857600
104857600=100MB
To display max_allowed_packet size limit use this command
show variables like 'max_allowed_packet';
Example: