Every now and then you’ll see an error like “Packet Too Large” in MySQL, as seen below. When you run into this, you’re trying to shove more information into a given SQL statement than is allowed. So to fix, you have a few different options, starting with the best, which is to make your SQL better.
But not everyone has control of things like source code. So you might need to change the value in mysql itself. To do so, simply run the mysql command with the –max_allowed_packet and then put = followed by the size of the packet. For example, to make it 128:
Now, by default this is 1M so that’s pretty big. You can then change it in the daemon:
And to change it in the my.cnf, simply edit /etc/my.cnf (on OS X) or /etc/mysql/my.cnf or /usr/local/mysql/my.cnf, according to how you installed mysql. From there, search for max_allowed_packet and change it as needed. Once changed, restart MySQL (or the server) and the changes will take effect.
krypted June 15th, 2013