Many MySQL programs have internal variables that can be set at
runtime. As of MySQL 4.0.2, program variables are set the same
way as any other long option that takes a value. For example,
mysql has a
max_allowed_packet variable that controls the
maximum size of its communication buffer. To set the
max_allowed_packet variable for
mysql to a value of 16MB, use either of the
following commands:
shell>mysql --max_allowed_packet=16777216shell>mysql --max_allowed_packet=16M
The first command specifies the value in bytes. The second
specifies the value in megabytes. For variables that take a
numeric value, the value can be given with a suffix of
K, M, or
G (either uppercase or lowercase) to indicate
a multiplier of 1024, 10242 or
10243. (For example, when used to set
max_allowed_packet, the suffixes indicate
units of kilobytes, megabytes, or gigabytes.)
In an option file, variable settings are given without the leading dashes:
[mysql] max_allowed_packet=16777216
Or:
[mysql] max_allowed_packet=16M
If you like, underscores in a variable name can be specified as dashes. The following option groups are equivalent. Both set the size of the server's key buffer to 512MB:
[mysqld] key_buffer_size=512M [mysqld] key-buffer-size=512M
Prior to MySQL 4.0.2, program variable names are not recognized
as option names. Instead, use the
--set-variable option to assign a value to a
variable:
shell>mysql --set-variable=max_allowed_packet=16777216shell>mysql --set-variable=max_allowed_packet=16M
In an option file, omit the leading dashes:
[mysql] set-variable = max_allowed_packet=16777216
Or:
[mysql] set-variable = max_allowed_packet=16M
With --set-variable, underscores in variable
names cannot be given as dashes for versions of MySQL older than
4.0.2.
The --set-variable option is still recognized
in MySQL 4.0.2 and up, but is deprecated.
Many server system variables can also be set at runtime. For details, see Section 5.2.4.2, “Dynamic System Variables”.

User Comments
you can set max_allowed_packet at the mysql prompt:
mysql> set global max_allowed_packet=16777216;
but using this form will NOT work
mysql> set global max_allowed_packet=16M;
ERROR 1232: Wrong argument type to variable 'max_allowed_packet'
Add your own comment.