MySQL Variables max_prepared_stmt_count 数据库 参数变量解释及正确配置使用

本站中文解释

max_prepared_stmt_count是MySQL的重要参数变量,主要用于限制MySQL中prepared statement的最大使用数量,其用途是保护MySQL服务器避免分配太多的资源被耗尽,或者避免被恶意攻击。

设置max_prepared_stmt_count的方法如下:

1. 在MySQL的配置文件中添加如下配置:

max_prepared_stmt_count=number

number表示可以使用的最大Prepared Statement数量,例如要设置最大数量为1000,则此变量可以设置为:

max_prepared_stmt_count=1000

2. 使用MySQL的set命令即时设置,例如设置最大数量为1000,可以使用如下指令:

set global max_prepared_stmt_count = 1000;

3. 通过MySQL的命令行工具可以使用如下语句设置,例如,最大数量为1000:

mysql> set global max_prepared_stmt_count = 1000;

官方英文解释

max_prepared_stmt_count

Command-Line Format --max-prepared-stmt-count=#
System Variable max_prepared_stmt_count
Scope Global
Dynamic Yes
Type Integer
Default Value 16382
Minimum Value 0
Maximum Value 1048576

This variable limits the total number of prepared statements
in the server. It can be used in environments where there is
the potential for denial-of-service attacks based on running
the server out of memory by preparing huge numbers of
statements. If the value is set lower than the current number
of prepared statements, existing statements are not affected
and can be used, but no new statements can be prepared until
the current number drops below the limit. Setting the value to
0 disables prepared statements.


数据运维技术 » MySQL Variables max_prepared_stmt_count 数据库 参数变量解释及正确配置使用