Configure max_allowed_packet on mySQL SERVER on AWS-EC2

Viewed 186

I have an EC2 instance created with a MySQL server instance installed. Since i am sending large blob data to be stored in the server, and the max_allowed_packet configuration is set to value 1048576, my service requests are failing.

I am trying to increase the size of the parameter to 16MB by using the below command via putty.

SET GLOBAL max_allowed_packet=16777216;

But there is no effect in the parameter. I tried restarting the sql server instance, still the effect isnt seen. When i run the below command again after setting the parameter, the same old value is shown 1048576.

SHOW VARIABLES LIKE 'max_allowed_packet'; 

What am i missing here?

1 Answers

Update the MySQL server's configuration file /etc/my.cnf under [mysqld] section with the new value for max_allowed_packet

[mysqld]
max_allowed_packet=16M

and restart the server.

Values set via SET statement are not persisted across server restarts and are applied only on the new client sessions created after the change.

Excerpt from the documentation,

If you change a global system variable, the value is remembered and used to initialize the session value for new sessions until you change the variable to a different value or the server exits. The change is visible to any client that accesses the global value. However, the change affects the corresponding session value only for clients that connect after the change. The global variable change does not affect the session value for any current client sessions (not even the session within which the global value change occurs).

Related