ERROR 2006 (HY000) at line 257: MySQL server has gone away
When doing a mysql dump to the database, if you get this error, it means that you have a connection timeout on the database or your restore is doing a chunk of data that exceeds the max allowed packets.
If you are on AWS follow the steps below
- Go to your RDS Dashboard and click Parameter Groups.
- Click Create DB Parameter Group, name it something like ‘LargeImport’, (making sure the DB Parameter Group Family you select matches your instance version) and edit the parameters.
- Increase the ‘max_allowed_packet‘ on ‘LargeImport’ to accommodate your import size (Valid values are 1024-1073741824).
- Increase the ‘wait_timeout‘ parameter to accommodate your import size. (Valid values are 1-31536000 seconds).
- Save your changes.
- Click Instances in the left column and select your instance.
- Click Instance Actions and choose Modify.
- Change the Parameter Group to your new ‘LargeImport’ group and click Continue.
- Click ‘Modify DB Instance’.
- Once the change has completed, click Instance Actions again and reboot your instance.
Once your instance has rebooted, you should be able to do larger sql imports.
Once you’ve completed your import, switch your instance parameter group back to the default parameter group and reboot it again.
On mysql server
Increase the settings in my.cnf file and restart mysql.