MySQLdump报错 mysqldump: Error 2020: Got packet bigger than ‘max_allowed_packet’ bytes when dumping table
今天在备份一个数据库时,执行mysqldump --user=root --password='xxx' --host=xxx.xxx.xxx.xxx --port=3306 --set-gtid-purged=OFF --flush-privileges --single-transaction --triggers --routines --events --hex-blob xxx > xxx.sql
命令后报错
mysqldump: Error 2020: Got packet bigger than 'max_allowed_packet' bytes when dumping table xxxx at row: 5212
出错原因是:导出的数据中有packet(数据包)大于mysql允许的packet大小,即大于--max-allowed-packet
的默认值
[root@ling:/opt/line_sql ]# mysqldump --help|grep max-allowed-packet
--max-allowed-packet=#
max-allowed-packet 25165824
解决方法:在导出时设置--max-allowed-packet
值的大小
mysqldump --user=root --password='xxx' --host=xxx.xxx.xxx.xxx --port=3306 --set-gtid-purged=OFF --flush-privileges --single-transaction --triggers --routines --events --hex-blob --max_allowed_packet=512M xxx > xxx.sql
参考:https://www.cnblogs.com/zuoxingyu/archive/2012/12/21/2828218.html
参考:http://blog.itpub.net/26506993/viewspace-2199827/