max_allowed_packet after mysql restart 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.
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:

https://stackoverflow.com/questions/2482234/how-to-know-mysql-my-cnf-location