Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysqldump error: Got packet bigger than max_allowed_packet'

My application download mails over IMAP and stores them in a MySQL database. Earlier I was supporting mails size upto 10 MB and hence a 'mediumtext' column to store the mail content was enough. Now I need to support mails upto 30MB. So I changed the datatype for the column to 'largetext'. Yesterday a mail with size 25 MB was stored. After that whenever I execute mysqldump command it throws error:

 mysqldump: Error 2020: Got packet bigger than 'max_allowed_packet' bytes when dumping table `ib_mailbox_backup` at row: 3369 

Row 3369 contains the 25 MB mail.

In MySQL config I increased the 'max_allowed_packet' from 64M to 512M and it still fails with the same error. Executing the mysqldump command on the same machine where MySQL server is running. How do I solve this?

like image 478
Varun Avatar asked Jan 11 '12 07:01

Varun


People also ask

Where is max_allowed_packet in MySQL?

Open the "my. ini" file under the MySQL server install directory. Search for the "max_allowed_packet" parameter.

What is max_allowed_packet?

In a nutshell, max_allowed_packet is the maximum size of a MySQL network protocol packet that the server can create or read. It has a default value of 1MB (<= 5.6. 5) or 4MB (>= 5.6. 6) and a maximum size of 1GB.

What is single transaction in Mysqldump?

Mysqldump with Transactions The --single-transaction flag will start a transaction before running. Rather than lock the entire database, this will let mysqldump read the database in the current state at the time of the transaction, making for a consistent data dump.


1 Answers

  1. You can add --max_allowed_packet=512M to your mysqldump command.
  2. Or add max_allowed_packet=512M to [mysqldump] section of your my.cnf (thanks @Varun)

Note: it will not work if it is not under the [mysqldump] section...

like image 82
Roman Newaza Avatar answered Sep 21 '22 18:09

Roman Newaza