I was getting the following errors when I was trying to restore a Request Tracker MySQL database in linux (Ubuntu to CentOS).

ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect…
Connection id: 10
Current database: rt4

ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect…
Connection id: 11
Current database: rt4

ERROR 2006 (HY000): MySQL server has gone away
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect…
Connection id: 12
Current database: rt4

These errors came later in the restore:

ERROR 1231 (42000): Variable ‘time_zone’ can’t be set to the value of ‘NULL’
ERROR 1231 (42000): Variable ‘sql_mode’ can’t be set to the value of ‘NULL’
ERROR 1231 (42000): Variable ‘foreign_key_checks’ can’t be set to the value of ‘NULL’
ERROR 1231 (42000): Variable ‘unique_checks’ can’t be set to the value of ‘NULL’
ERROR 1231 (42000): Variable ‘character_set_client’ can’t be set to the value of ‘NULL’
Query OK, 0 rows affected (0.00 sec)

ERROR 1231 (42000): Variable ‘collation_connection’ can’t be set to the value of ‘NULL’
ERROR 1231 (42000): Variable ‘sql_notes’ can’t be set to the value of ‘NULL’

To get the database restored, I had to change the maximum allowed packet setting.

The best way to do that is to add the following line to the [mysqld] section of the my.cnf (CentOS: /etc/my.cnf or Ubuntu: /etc/mysql/my.cnf):

max_allowed_packet = 16M

Then, restart your MySQL service.
Ubuntu: service mysql restart
CentOS: service mysqld restart

Now, I did this on both of my servers, then I could use my regular backup script and the setting would be picked up by the my.cnf. However, you can do the backup with option enabled if it is not in your my.cnf by using something like the following:

mysqldump $thedb –user=”myid” –password=”$SQLPWD” –max_allowed_packet=16M > $thedb.sql