MySQL error 2006: mysql server has gone away

I've encountered this a number of times and I've normally found the answer to be a very low default setting of max_allowed_packet.

Raising it in /etc/my.cnf (under [mysqld]) to 8 or 16M usually fixes it. (The default in MySql 5.7 is 4194304, which is 4MB.)

[mysqld]
max_allowed_packet=16M

Note: Just create the line if it does not exist

Note: This can be set on your server as it's running.

Note: On Windows you may need to say your my.ini or my.cnf file with ANSI not UTF-8 encoding.

Use set global max_allowed_packet=104857600. This sets it to 100MB.


I had the same problem but changeing max_allowed_packet in the my.ini/my.cnf file under [mysqld] made the trick.

add a line

max_allowed_packet=500M

now restart the MySQL service once you are done.