There are several ways of changing the max_allowed_packet value. It is primarily set to the default value, which is 16MB.
To change it, follow this:
$> mysql --max_allowed_packet=32M
This will set the client's value to 32 MB. You can change the value according to your requirements.
Changing the server value is also important, especially when you are dealing with large queries. Usually, the server's default value is 16 MB.
Let's double the server's value, as we did to the client's program:
$> mysqld --max_allowed_packet=32M
Lastly, you can also set the value using an configuration file. Here's how it is done:
This will change the server size to 32 MB, thus enabling it to transfer larger queries without any error.