Many MySQL programs have internal variables that are set at run time using the SET statement. Most program variables can also be set at server startup, using the same syntax as specifying program options.
mysql has a max_allowed_packet variable that controls the maximum size of its communication buffer.
To set the max_allowed_packet variable of mysql to 16MB, you can use the commands mentioned below -
mysql --max_allowed_packet=16777216 (or) mysql --max_allowed_packet=16M
The first command specifies the value in bytes. The second command, on the other hand, specifies the value in megabytes (MB, or M).
For variables with numeric values, the value can be given with the help of the suffix K, M or G to represent a multiplier of 1024, 10242 or 10243.
In the options file, variable settings will be provided without the leading dash -
[mysql] max_allowed_packet=16777216 (or) [mysql] max_allowed_packet=16M
If desired, underscores can be specified as dashes in option names . The option groups mentioned below are all equivalent.
They both set the server key buffer size to 512MB.
[mysqld] key_buffer_size=512M (or) [mysqld] key-buffer-size=512M
The above is the detailed content of Setting MySQL program variables using options. For more information, please follow other related articles on the PHP Chinese website!