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

Getting MYSQL server has gone away when importing database from .sql file

Problem: You are trying to import a .sql file using the command line mysql command but it is unsuccessful as follows:

# mysql -u douser -pdbpass yourdb < db_file.sql
ERROR 2006 (HY000) at line XXXXX: MySQL server has gone away

The solution is to edit /etc/my.cnf and add the following line to the [mysqld] section:

max_allowed_packet=64M

Then restart mysql:

# service mysqld restart

Re-run your import query (you may need to delete the partly database first and re-create it) and it will now succeed.

Was this helpful?