MySQL: how to fix ‘ERROR 2006 (HY000) at line ##: MySQL server has gone away’

If you get mentioned error while restoring big database, make sure you have enough size of max_allowed_packet.

[mysqld]
max_allowed_packet=64M

After adding it to your /etc/my.cnf restart MySQL server to apply changes.