2017-05-16

mysqldump: Error 2020: Got packet bigger than 'max_allowed_packet' bytes when dumping table

In some cases you cane receive error when use mysqldump on tables with longblog columns.

For example:
mysqldump somedb Attachment > somedb.Attachment.mysqldump
mysqldump: Error 2020: Got packet bigger than 'max_allowed_packet' bytes when dumping table `Attachment` at row: 1005

In spite of the fact that on server side you setup enough value for max_allowed_packet, you will still receive this error.

As we can read in official documentation(Packet Too Large), max_allowed_packet must be set on both sides(client and server) to enough value.

The way you can do this:
mysqldump --max_allowed_packet=1024M somedb Attachment > somedb.Attachment.mysqldump

It is highly recommended to use mysqldump in this way in all cases when you work with databases with longblog, because it is have no bad influence on any things, but you will always have good backups.
Читать далее