I've read many articles that explain how to accomplish this but I've reached the conclusion that they simply haven't tested it properly. My conclusions are:
Server's
max_allowed_packet
is a hard-coded upper limit. You can change it for the whole server as any other server-side setting (configuration file or server command-line parameters) but it isn't possible to increase it from the client.Some clients (such as the official command line utility) allow to set
max_allowed_packet
on connection. It's the only way to actually change the value from a client (changing session or global variables has no effect on the size of exchanged packages) but it's only useful if you want to lower it. Sending packages larger than the server's setting will still trigger package related errors since the server will not accept them.
To sum up:
- You have to treat
max_allowed_packet
as read-only. - If it's too small, you need to change it for the whole server or live with it.
It's a pity that I cannot provide links to official documentation but this subject is poorly documented.