Monday, May 7, 2012

MySQL: MySQL server has gone away

Issue: I need to restore quite big mysql db to local db server using mysql restore command, but got this error.
 ERROR 2006 (HY000) at line XXX: MySQL server has gone away

 SOLUTION: 

  1. Stop mysql-server
    # /usr/local/etc/rc.d/mysql-server stop
  2. Open file my.cnf in mysql directory 
  3. Add this 2 line:
    [mysqldump]
    quick max_allowed_packet = 16M

    [mysqld]
    max_allowed_packet=32M

    [mysql]
    max_allowed_packet=32M
  4. Start mysql-server back
    # /usr/local/etc/rc.d/mysql-server start
  5. Try restore the mysql db again
    # mysql -uroot -p --default-character-set=utf8  <  filenamexxxx.sql
    **It works for me. Try it yourself.

    .

0 comments:

Post a Comment