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

前端 未结 3 973
粉色の甜心
粉色の甜心 2021-01-01 14:14

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         


        
相关标签:
3条回答
  • 2021-01-01 14:35

    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)
  • 2021-01-01 14:51

    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.

    0 讨论(0)
  • 2021-01-01 14:58

    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.

    0 讨论(0)
提交回复
热议问题