Home  >  Article  >  Database  >  Setting MySQL program variables using options

Setting MySQL program variables using options

WBOY
WBOYforward
2023-09-14 08:13:08715browse

使用选项设置 MySQL 程序变量

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.

Example 1

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.

Example 2

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete