There are three ways to enlarge the max_allowed_packet of mysql server:
- Change
max_allowed_packet=64M
in file/etc/mysql/my.cnf
on the mysql server machine and restart the server - Execute the sql on the mysql server:
set global max_allowed_packet=67108864;
- Python executes sql after connecting to the mysql:
只要执行:set global max_allowed_packet=67108864;就可以了!