Encountered an error when writing data:
django.db.utils.InternalError: (1153, "Got a packet bigger than 'max_allowed_packet' bytes")
After querying that the max_allowed_packet
value is set too small, mysql reports an error, limiting the size of the data packet accepted by the server.
Enter the mysql console through the terminal
mysql -hlocalhost -uroot -p
Enter the following command to view the value of max_allowed_packet
.
show VARIABLES like '%max_allowed_packet%';
max_allowed_packet 1024
slave_max_allowed_packet 1073741824
The current mysql max_allowed_packet size is 1k
1. Temporary modification method is only applicable to mysql without restarting, once the restart configuration information becomes invalid.
# set to 10m
set global max_allowed_packet = 1048576*10
2. Modify the my.cnf
configuration file (after restarting the mysql service, it will take effect permanently)
max_allowed_packet=20M
The mysql command is as follows:
startup
service mysqld start
/etc/inint.d/mysqld start
safe_mysqld&
stop
service mysqld stop
/etc/inint.d/mysqld stop
mysqladmin shutdown
restart
service mysqld restart
/etc/inint.d/mysqld restart