If you get an error like this in response to a query:
ERROR 1153 (08S01) at line 1: Got a packet bigger than 'max_allowed_packet' bytes
then it's obvious that the query you built (or the software that's talking to MySQL) is too long to be processed.
There are two ways to fix this:
- If you wrote the software yourself (say, it's a website or just your own program) - optimize the query so it fits within the standard 65535-character length.
- If you can't change the query length - then change the max_allowed_packet variable in the configuration file.
Checking the current valueYou can check the value of max_allowed_packet with a query right in MySQL itself:
mysql> SHOW VARIABLES LIKE 'max_allowed_packet';
Changing the max_allowed_packet valueTo do this, open the my.cnf file for editing.
Now, in the [mysqld] section, add (or change, if it's already there) the line:
max_allowed_packet = 32M
where instead of 32M - substitute whatever value you need.
The default is usually 16M (16*1024*1024).
After making the change - restart the MySQL service.
for Debian/ubuntu:
$ sudo /etc/init.d/mysql restart
for CentOS/RedHat:
$ sudo /etc/init.d/mysqld restart
for FreeBSD:
$ sudo /usr/local/etc/rc.d/mysql-server restart
Comments