I want to set max_allowed_packet parameter in runtime. The

SET GLOBAL max_allowed_packet = 16777216

works for new connections, but after database server restart, it has previous value. Can value of the max_allowed_packet in runtime for new connection and restart of database server will not affect this value?

Thank you.

  • 1
    set the value again globally and add the new value in config file so after restart it comes back to what you want or you can use init_file and set the value of your need in it as it would be read at instance start-up Commented Apr 6, 2016 at 14:55

1 Answer 1


Setting in the command line are not persisted anywhere. Therefore after a restart it resets to default or picks up the value from the config file.

Put the following line into your my.cnf file under the [mysqld] section:

max_allowed_packet = 16777216

About how to find what file is used you can find some resources here on stack exchange as well:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.