How to dump a large database? I try to take a backup of a huge MySQL database via mysqldump. The database has millions of rows with a total size of 1.3TB.

CREATE TABLE PageContents
(
ID int(11) unsigned,
Added date,
Text MEDIUMTEXT,
FOREIGN KEY(ID) REFERENCES AllPages(ID) ON DELETE CASCADE,
PRIMARY KEY(ID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci KEY_BLOCK_SIZE=1;


but I receive an error after 8 hours of dumping:

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


I had increased max_allowed_packet in mysql.cnf

max_allowed_packet  = 16G
First, make sure you have set max_allowed_packet in the appropriate section [mysqldump] of the config file my.cnf and that it does not exceed the maximal value of 1G:

[mysqldump]
max_allowed_packet=1G


Or you can also specify it at runtime (without having to change my.cnf):

mysqldump --max-allowed-packet=1G ...