20

I have a MYSQL dump from a database that I am trying to move to a new db server. When I try to import my sql dump, I receive the following error:

MySQL Error 2006 (HY000) at line 406: MySQL server has gone away

I googled the problem and most people fixed the problem by changing the value of wait_timeout. However, my current value is set to 28800 (8 hours) and the error appears in less than 8 seconds when I run the import.

I also tried setting the value of max_allowed_packet to 1073741824 but that also did not fix the problem.

Looking through the mysql dump, there are quite a few blob columns in the dump, but the overall file size is only 6 MB.

Does anyone have any ideas about what else might be the problem?

1
  • 2
    As a workaround, I went back to the source database server and make several smaller dump files (5 tables at a time). Then, I imported each of the smaller dump files and this let me accomplish my database transfer without the error message.
    – David
    Jan 5, 2012 at 15:31

3 Answers 3

48

Adding this answer for the benefit of future searchers, as it explains why increasing the packet size fixed the problem:

The situation is that if a client sends a SQL-statement longer than the server max_allowed_packet setting, the server will simply disconnect the client. Next query from the same client instance will find that the ‘MySQL server has gone away’.

... But it would of course be much preferable to have the ‘got packet bigger’ error [Error: 2020 (CR_NET_PACKET_TOO_LARGE)] returned if that is the problem.

Excerpted from and thanks for peter_laursen's blog post

On OSX 10.7 (Lion), I created a file, /etc/my.cnf with the following contents:

[mysqld]
max_allowed_packet = 12000000

And then stopped the mysql server:

/usr/local/bin/mysql.server stop

When it automatically restarted I was able to execute my inserts.

3
  • 1
    Well I got the same problem even for max_allowed_packet = 512M Oct 18, 2013 at 8:09
  • 1
    @AbhijitBuchake - then it's likely not a 'packet too large' problem, but some other reason for the disconnect. Unfortunately, I don't have any other suggestions for you. Oct 21, 2013 at 15:26
  • 1
    THANK YOU! I have read and tried over a dozen scenarios. I have re-installed mysql 3 times. The above trick for the my.cnf fix it. I was trying to add a 50m mysql database into mysql through command line. That totally made my day!
    – user24793
    Nov 13, 2015 at 19:43
6

Increasing max_allowed_packet to 12 MB (12000000) solved the problem for me when trying to import a 130 MB file.

Change the ini file or under Options File / Networking in MySQL Workbench (MySQL restart required).

If you still get the error, try increasing even more (100 MB). Just remember to decrease it when you're done.

0
0

1) Change in MySql config file: # /etc/mysql/my.cnf

#section 
#
[mysqld]
#
key_buffer              = 32M
max_allowed_packet      = 32M
thread_stack            = 512K
thread_cache_size       = 64
#

2) MySql deamon restart

/etc/init.d/mysql restart 

Should resolve yours issues.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.