ERROR 2006 (HY000) at line ####: MySQL server has gone away

One of those very helpful error messages. I got this error when importing a large database, and it was caused by some insert statements exceeding the configured max_allowed_packet size (manual). According to this bug entry, the error message should actually say

Got a packet bigger than 'max_allowed_packet' bytes

but that doesn’t seem to fixed to this day. To fix the error, simply increase max_allowed_packet in your my.cnf file, under the [mysqld] section, e.g.

[mysqld]
max_allowed_packet = 16M

3 thoughts on “ERROR 2006 (HY000) at line ####: MySQL server has gone away

      • As far as I know, you can’t judge the max_allowed_packet directly from the size of the SQL file, given that the largest query in that SQL file dictates the max_allowed_packet value. In other words, packet size of 1M might be enough for an SQL file of 10GB, if that file only contains small queries. You should simply try doubling the max_allowed_packet value if your MySQL server still “goes away”, and if it doesn’t work after 5 or so iterations (starting at 16M), the problem probably lies somewhere else.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>