MySQL5.7 使用系统变量

官网地址:MySQL :: MySQL 5.7 Reference Manual :: 5.1.8 Using System Variables

欢迎关注留言,我是收集整理小能手,工具翻译,仅供参考,笔芯笔芯.

MySQL 5.7 参考手册 / ... / 使用系统变量

5.1.8 使用系统变量

5.1.8.1 系统变量权限

5.1.8.2 动态系统变量

5.1.8.3 结构化系统变量

MySQL 服务器维护许多配置其操作的系统变量。第 5.1.7 节"服务器系统变量"描述了这些变量的含义。每个系统变量都有一个默认值。可以在服务器启动时使用命令行或选项文件中的选项设置系统变量。其中大多数可以在服务器运行时通过语句动态更改 SET ,这使您无需停止并重新启动服务器即可修改服务器的操作。您还可以在表达式中使用系统变量值。

许多系统变量是内置的。由服务器插件实现的系统变量在安装插件时公开,并且其名称以插件名称开头。例如,该 audit_log插件实现了一个名为 的系统变量audit_log_policy

系统变量存在两个范围。全局变量影响服务器的整体运行。会话变量影响各个客户端连接的操作。给定的系统变量可以同时具有全局值和会话值。全局变量和会话系统变量的关系如下:

  • 当服务器启动时,它将每个全局变量初始化为其默认值。这些默认值可以通过命令行或选项文件中指定的选项进行更改。(请参见 第 4.2.2 节"指定程序选项"。)

  • 服务器还为每个连接的客户端维护一组会话变量。客户端的会话变量在连接时使用相应全局变量的当前值进行初始化。例如,客户端的SQL模式由会话 sql_mode值控制,该会话值在客户端连接到全局值的值时初始化sql_mode

    对于某些系统变量,会话值不是从相应的全局值初始化的;如果是这样,则会在变量描述中指出。

系统变量值可以在服务器启动时使用命令行或选项文件中的选项进行全局设置。启动时,系统变量的语法与命令选项的语法相同,因此在变量名称中,破折号和下划线可以互换使用。例如 --general_log=ON--general-log=ON是等价的。

当您使用启动选项设置采用数值的变量时,可以使用后缀 KM、 或 G(大写或小写)来指定该值,以指示乘数 1024、1024 2或 1024 3;即分别以千字节、兆字节或千兆字节为单位。因此,以下命令启动服务器,InnoDB日志文件大小为 16 MB,最大数据包大小为 1 GB:

language-terminal 复制代码
mysqld --innodb-log-file-size=16M --max-allowed-packet=1G

在选项文件中,这些变量的设置如下:

language-ini 复制代码
[mysqld]
innodb_log_file_size=16M
max_allowed_packet=1G

后缀字母的大小写无关紧要; 16M16m是等价的,就像1G和 一样1g

要限制在运行时使用语句设置系统变量的最大值 SET ,请在服务器启动时使用以下形式的选项指定该最大值 。例如,要防止 的值 在运行时增加到超过 32MB,请使用选项 。 --maximum-var_name =valueinnodb_log_file_size--maximum-innodb-log-file-size=32M

许多系统变量是动态的,可以在运行时使用 SET 语句进行更改。有关列表,请参见 第 5.1.8.2 节 "动态系统变量"。要使用 更改系统变量 SET,请按名称引用它,可以在前面加上修饰符。在运行时,系统变量名称必须使用下划线编写,而不是破折号。以下示例简要说明了此语法:

  • 设置全局系统变量:

    language-sql 复制代码
    SET GLOBAL max_connections = 1000;
    SET @@GLOBAL.max_connections = 1000;
  • 设置会话系统变量:

    language-sql 复制代码
    SET SESSION sql_mode = 'TRADITIONAL';
    SET @@SESSION.sql_mode = 'TRADITIONAL';
    SET @@sql_mode = 'TRADITIONAL';

有关 SET 语法的完整详细信息,请参见第 13.7.4.1 节 "变量赋值的 SET 语法"。有关设置系统变量的权限要求的描述,请参见 第 5.1.8.1 节 "系统变量权限"

在服务器启动时设置变量时可以使用用于指定值乘数的后缀,但不能SET 在运行时设置值。另一方面, SET您可以使用表达式分配变量的值,但在服务器启动时设置变量时则不然。例如,以下行中的第一行在服务器启动时是合法的,但第二行则不是:

language-terminal 复制代码
$> mysql --max_allowed_packet=16M
$> mysql --max_allowed_packet=16*1024*1024

相反,以下行中的第二行在运行时是合法的,但第一行不是:

language-terminal 复制代码
mysql> SET GLOBAL max_allowed_packet=16M;
mysql> SET GLOBAL max_allowed_packet=16*1024*1024;

要显示系统变量名称和值,请使用以下 SHOW VARIABLES语句:

language-sql 复制代码
mysql> SHOW VARIABLES;
+---------------------------------+-----------------------------------+
| Variable_name                   | Value                             |
+---------------------------------+-----------------------------------+
| auto_increment_increment        | 1                                 |
| auto_increment_offset           | 1                                 |
| automatic_sp_privileges         | ON                                |
| back_log                        | 50                                |
| basedir                         | /home/mysql/                      |
| binlog_cache_size               | 32768                             |
| bulk_insert_buffer_size         | 8388608                           |
| character_set_client            | utf8                              |
| character_set_connection        | utf8                              |
| character_set_database          | latin1                            |
| character_set_filesystem        | binary                            |
| character_set_results           | utf8                              |
| character_set_server            | latin1                            |
| character_set_system            | utf8                              |
| character_sets_dir              | /home/mysql/share/mysql/charsets/ |
| collation_connection            | utf8_general_ci                   |
| collation_database              | latin1_swedish_ci                 |
| collation_server                | latin1_swedish_ci                 |
...
| innodb_autoextend_increment     | 8                                 |
| innodb_buffer_pool_size         | 8388608                           |
| innodb_checksums                | ON                                |
| innodb_commit_concurrency       | 0                                 |
| innodb_concurrency_tickets      | 500                               |
| innodb_data_file_path           | ibdata1:10M:autoextend            |
| innodb_data_home_dir            |                                   |
...
| version                         | 5.7.18-log                        |
| version_comment                 | Source distribution               |
| version_compile_machine         | i686                              |
| version_compile_os              | suse-linux                        |
| wait_timeout                    | 28800                             |
+---------------------------------+-----------------------------------+

使用LIKE子句时,语句仅显示与模式匹配的变量。要获取特定变量名称,请使用LIKE 如下所示的子句:

language-sql 复制代码
SHOW VARIABLES LIKE 'max_join_size';
SHOW SESSION VARIABLES LIKE 'max_join_size';

要获取名称与模式匹配的变量列表,请 %在子句中使用通配符 LIKE

language-sql 复制代码
SHOW VARIABLES LIKE '%size%';
SHOW GLOBAL VARIABLES LIKE '%size%';

通配符可以用在要匹配的模式内的任何位置。严格来说,因为_是匹配任何单个字符的通配符,所以您应该将其转义以按\_字面匹配。实际上,这很少有必要。

对于SHOW VARIABLES,如果您既不指定GLOBAL也不指定SESSION,MySQL 将返回SESSION值。

GLOBAL在设置 -only 变量时 需要关键字,但在检索变量时不需要关键字的原因GLOBAL是为了防止将来出现问题:

  • 如果SESSION要删除的变量与某个变量同名GLOBAL,则具有足以修改全局变量的权限的客户端可能会意外更改该GLOBAL 变量,而不仅仅是SESSION 其自己会话的变量。

  • 如果SESSION要添加与变量同名的变量GLOBAL,则打算更改该GLOBAL 变量的客户端可能会发现只更改了自己的SESSION 变量。

MySQL 5.7 参考手册 / ... / 系统变量权限

5.1.8.1 系统变量权限

系统变量可以具有影响整个服务器操作的全局值、仅影响当前会话的会话值或两者。要修改系统变量运行时值,请使用该 SET 语句。请参见第 13.7.4.1 节"变量赋值的 SET 语法"。本节描述在运行时为系统变量赋值所需的权限。

设置全局系统变量运行时值需要该 SUPER权限。

要设置会话系统变量运行时值,请使用该 SET SESSION语句。与设置全局运行时值相比,设置会话运行时值通常不需要特殊权限,并且任何用户都可以执行此操作来影响当前会话。对于某些系统变量,设置会话值可能会在当前会话之外产生影响,因此是一项受限操作,只有具有权限的用户才能完成 SUPER。如果会话系统变量以这种方式受到限制,则变量描述会指示该限制。示例包括 binlog_formatsql_log_bin。设置这些变量的会话值会影响当前会话的二进制日志记录,但也可能对服务器复制和备份的完整性产生更广泛的影响。

MySQL 5.7 参考手册 / ... / 动态系统变量

5.1.8.2 动态系统变量

许多服务器系统变量是动态的,可以在运行时设置。请参见第 13.7.4.1 节"变量赋值的 SET 语法"。有关设置系统变量的权限要求的描述,请参见 第 5.1.8.1 节 "系统变量权限"

下表列出了 中适用的所有动态系统变量mysqld

该表列出了每个变量的数据类型和范围。最后一列指示每个变量的范围是全局、会话还是两者。有关变量的设置和使用的详细信息,请参见相应项目的说明。在适当的情况下,提供有关该项目的更多信息的直接链接。

具有"字符串" 类型的变量采用字符串值。具有"数字"类型的变量 采用数字值。具有"布尔"类型的变量可以设置为 0、1 ONOFF。标记为"枚举"的变量通常应设置为该变量的可用值之一,但也可以设置为与所需枚举值相对应的数字。对于枚举系统变量,第一个枚举值对应于 0。这与 ENUM用于表列的数据类型,第一个枚举值对应于 1。

表 5.4 动态系统变量汇总

| Variable Name | Variable Type | Variable Scope |
| audit_log_connection_policy | Enumeration | Global |
| audit_log_disable | Boolean | Global |
| audit_log_exclude_accounts | String | Global |
| audit_log_flush | Boolean | Global |
| audit_log_format_unix_timestamp | Boolean | Global |
| audit_log_include_accounts | String | Global |
| audit_log_read_buffer_size | Integer | Varies |
| audit_log_rotate_on_size | Integer | Global |
| audit_log_statement_policy | Enumeration | Global |
| authentication_ldap_sasl_auth_method_name | String | Global |
| authentication_ldap_sasl_bind_base_dn | String | Global |
| authentication_ldap_sasl_bind_root_dn | String | Global |
| authentication_ldap_sasl_bind_root_pwd | String | Global |
| authentication_ldap_sasl_ca_path | String | Global |
| authentication_ldap_sasl_group_search_attr | String | Global |
| authentication_ldap_sasl_group_search_filter | String | Global |
| authentication_ldap_sasl_init_pool_size | Integer | Global |
| authentication_ldap_sasl_log_status | Integer | Global |
| authentication_ldap_sasl_max_pool_size | Integer | Global |
| authentication_ldap_sasl_server_host | String | Global |
| authentication_ldap_sasl_server_port | Integer | Global |
| authentication_ldap_sasl_tls | Boolean | Global |
| authentication_ldap_sasl_user_search_attr | String | Global |
| authentication_ldap_simple_auth_method_name | String | Global |
| authentication_ldap_simple_bind_base_dn | String | Global |
| authentication_ldap_simple_bind_root_dn | String | Global |
| authentication_ldap_simple_bind_root_pwd | String | Global |
| authentication_ldap_simple_ca_path | String | Global |
| authentication_ldap_simple_group_search_attr | String | Global |
| authentication_ldap_simple_group_search_filter | String | Global |
| authentication_ldap_simple_init_pool_size | Integer | Global |
| authentication_ldap_simple_log_status | Integer | Global |
| authentication_ldap_simple_max_pool_size | Integer | Global |
| authentication_ldap_simple_server_host | String | Global |
| authentication_ldap_simple_server_port | Integer | Global |
| authentication_ldap_simple_tls | Boolean | Global |
| authentication_ldap_simple_user_search_attr | String | Global |
| auto_increment_increment | Integer | Both |
| auto_increment_offset | Integer | Both |
| autocommit | Boolean | Both |
| automatic_sp_privileges | Boolean | Global |
| avoid_temporal_upgrade | Boolean | Global |
| big_tables | Boolean | Both |
| binlog_cache_size | Integer | Global |
| binlog_checksum | String | Global |
| binlog_direct_non_transactional_updates | Boolean | Both |
| binlog_error_action | Enumeration | Global |
| binlog_format | Enumeration | Both |
| binlog_group_commit_sync_delay | Integer | Global |
| binlog_group_commit_sync_no_delay_count | Integer | Global |
| binlog_max_flush_queue_time | Integer | Global |
| binlog_order_commits | Boolean | Global |
| binlog_row_image | Enumeration | Both |
| binlog_rows_query_log_events | Boolean | Both |
| binlog_stmt_cache_size | Integer | Global |
| binlog_transaction_dependency_history_size | Integer | Global |
| binlog_transaction_dependency_tracking | Enumeration | Global |
| block_encryption_mode | String | Both |
| bulk_insert_buffer_size | Integer | Both |
| character_set_client | String | Both |
| character_set_connection | String | Both |
| character_set_database | String | Both |
| character_set_filesystem | String | Both |
| character_set_results | String | Both |
| character_set_server | String | Both |
| check_proxy_users | Boolean | Global |
| collation_connection | String | Both |
| collation_database | String | Both |
| collation_server | String | Both |
| completion_type | Enumeration | Both |
| concurrent_insert | Enumeration | Global |
| connect_timeout | Integer | Global |
| connection_control_failed_connections_threshold | Integer | Global |
| connection_control_max_connection_delay | Integer | Global |
| connection_control_min_connection_delay | Integer | Global |
| debug | String | Both |
| debug_sync | String | Session |
| default_password_lifetime | Integer | Global |
| default_storage_engine | Enumeration | Both |
| default_tmp_storage_engine | Enumeration | Both |
| default_week_format | Integer | Both |
| delay_key_write | Enumeration | Global |
| delayed_insert_limit | Integer | Global |
| delayed_insert_timeout | Integer | Global |
| delayed_queue_size | Integer | Global |
| div_precision_increment | Integer | Both |
| end_markers_in_json | Boolean | Both |
| enforce_gtid_consistency | Enumeration | Global |
| eq_range_index_dive_limit | Integer | Both |
| event_scheduler | Enumeration | Global |
| expire_logs_days | Integer | Global |
| explicit_defaults_for_timestamp | Boolean | Both |
| flush | Boolean | Global |
| flush_time | Integer | Global |
| foreign_key_checks | Boolean | Both |
| ft_boolean_syntax | String | Global |
| general_log | Boolean | Global |
| general_log_file | File name | Global |
| group_concat_max_len | Integer | Both |
| group_replication_allow_local_disjoint_gtids_join | Boolean | Global |
| group_replication_allow_local_lower_version_join | Boolean | Global |
| group_replication_auto_increment_increment | Integer | Global |
| group_replication_bootstrap_group | Boolean | Global |
| group_replication_components_stop_timeout | Integer | Global |
| group_replication_compression_threshold | Integer | Global |
| group_replication_enforce_update_everywhere_checks | Boolean | Global |
| group_replication_exit_state_action | Enumeration | Global |
| group_replication_flow_control_applier_threshold | Integer | Global |
| group_replication_flow_control_certifier_threshold | Integer | Global |
| group_replication_flow_control_mode | Enumeration | Global |
| group_replication_force_members | String | Global |
| group_replication_group_name | String | Global |
| group_replication_group_seeds | String | Global |
| group_replication_gtid_assignment_block_size | Integer | Global |
| group_replication_ip_whitelist | String | Global |
| group_replication_local_address | String | Global |
| group_replication_member_weight | Integer | Global |
| group_replication_poll_spin_loops | Integer | Global |
| group_replication_recovery_complete_at | Enumeration | Global |
| group_replication_recovery_reconnect_interval | Integer | Global |
| group_replication_recovery_retry_count | Integer | Global |
| group_replication_recovery_ssl_ca | String | Global |
| group_replication_recovery_ssl_capath | String | Global |
| group_replication_recovery_ssl_cert | String | Global |
| group_replication_recovery_ssl_cipher | String | Global |
| group_replication_recovery_ssl_crl | File name | Global |
| group_replication_recovery_ssl_crlpath | Directory name | Global |
| group_replication_recovery_ssl_key | String | Global |
| group_replication_recovery_ssl_verify_server_cert | Boolean | Global |
| group_replication_recovery_use_ssl | Boolean | Global |
| group_replication_single_primary_mode | Boolean | Global |
| group_replication_ssl_mode | Enumeration | Global |
| group_replication_start_on_boot | Boolean | Global |
| group_replication_transaction_size_limit | Integer | Global |
| group_replication_unreachable_majority_timeout | Integer | Global |
| gtid_executed_compression_period | Integer | Global |
| gtid_mode | Enumeration | Global |
| gtid_next | Enumeration | Session |
| gtid_purged | String | Global |
| host_cache_size | Integer | Global |
| identity | Integer | Session |
| init_connect | String | Global |
| init_slave | String | Global |
| innodb_adaptive_flushing | Boolean | Global |
| innodb_adaptive_flushing_lwm | Integer | Global |
| innodb_adaptive_hash_index | Boolean | Global |
| innodb_adaptive_max_sleep_delay | Integer | Global |
| innodb_api_bk_commit_interval | Integer | Global |
| innodb_api_trx_level | Integer | Global |
| innodb_autoextend_increment | Integer | Global |
| innodb_background_drop_list_empty | Boolean | Global |
| innodb_buffer_pool_dump_at_shutdown | Boolean | Global |
| innodb_buffer_pool_dump_now | Boolean | Global |
| innodb_buffer_pool_dump_pct | Integer | Global |
| innodb_buffer_pool_filename | File name | Global |
| innodb_buffer_pool_load_abort | Boolean | Global |
| innodb_buffer_pool_load_now | Boolean | Global |
| innodb_buffer_pool_size | Integer | Global |
| innodb_change_buffer_max_size | Integer | Global |
| innodb_change_buffering | Enumeration | Global |
| innodb_change_buffering_debug | Integer | Global |
| innodb_checksum_algorithm | Enumeration | Global |
| innodb_cmp_per_index_enabled | Boolean | Global |
| innodb_commit_concurrency | Integer | Global |
| innodb_compress_debug | Enumeration | Global |
| innodb_compression_failure_threshold_pct | Integer | Global |
| innodb_compression_level | Integer | Global |
| innodb_compression_pad_pct_max | Integer | Global |
| innodb_concurrency_tickets | Integer | Global |
| innodb_deadlock_detect | Boolean | Global |
| innodb_default_row_format | Enumeration | Global |
| innodb_disable_resize_buffer_pool_debug | Boolean | Global |
| innodb_disable_sort_file_cache | Boolean | Global |
| innodb_fast_shutdown | Integer | Global |
| innodb_fil_make_page_dirty_debug | Integer | Global |
| innodb_file_format | String | Global |
| innodb_file_format_max | String | Global |
| innodb_file_per_table | Boolean | Global |
| innodb_fill_factor | Integer | Global |
| innodb_flush_log_at_timeout | Integer | Global |
| innodb_flush_log_at_trx_commit | Enumeration | Global |
| innodb_flush_neighbors | Enumeration | Global |
| innodb_flush_sync | Boolean | Global |
| innodb_flushing_avg_loops | Integer | Global |
| innodb_ft_aux_table | String | Global |
| innodb_ft_enable_diag_print | Boolean | Global |
| innodb_ft_enable_stopword | Boolean | Both |
| innodb_ft_num_word_optimize | Integer | Global |
| innodb_ft_result_cache_limit | Integer | Global |
| innodb_ft_server_stopword_table | String | Global |
| innodb_ft_user_stopword_table | String | Both |
| innodb_io_capacity | Integer | Global |
| innodb_io_capacity_max | Integer | Global |
| innodb_large_prefix | Boolean | Global |
| innodb_limit_optimistic_insert_debug | Integer | Global |
| innodb_lock_wait_timeout | Integer | Both |
| innodb_log_checkpoint_now | Boolean | Global |
| innodb_log_checksums | Boolean | Global |
| innodb_log_compressed_pages | Boolean | Global |
| innodb_log_write_ahead_size | Integer | Global |
| innodb_lru_scan_depth | Integer | Global |
| innodb_max_dirty_pages_pct | Numeric | Global |
| innodb_max_dirty_pages_pct_lwm | Numeric | Global |
| innodb_max_purge_lag | Integer | Global |
| innodb_max_purge_lag_delay | Integer | Global |
| innodb_max_undo_log_size | Integer | Global |
| innodb_merge_threshold_set_all_debug | Integer | Global |
| innodb_monitor_disable | String | Global |
| innodb_monitor_enable | String | Global |
| innodb_monitor_reset | Enumeration | Global |
| innodb_monitor_reset_all | Enumeration | Global |
| innodb_old_blocks_pct | Integer | Global |
| innodb_old_blocks_time | Integer | Global |
| innodb_online_alter_log_max_size | Integer | Global |
| innodb_optimize_fulltext_only | Boolean | Global |
| innodb_print_all_deadlocks | Boolean | Global |
| innodb_purge_batch_size | Integer | Global |
| innodb_purge_rseg_truncate_frequency | Integer | Global |
| innodb_random_read_ahead | Boolean | Global |
| innodb_read_ahead_threshold | Integer | Global |
| innodb_replication_delay | Integer | Global |
| innodb_rollback_segments | Integer | Global |
| innodb_saved_page_number_debug | Integer | Global |
| innodb_spin_wait_delay | Integer | Global |
| innodb_stats_auto_recalc | Boolean | Global |
| innodb_stats_include_delete_marked | Boolean | Global |
| innodb_stats_method | Enumeration | Global |
| innodb_stats_on_metadata | Boolean | Global |
| innodb_stats_persistent | Boolean | Global |
| innodb_stats_persistent_sample_pages | Integer | Global |
| innodb_stats_sample_pages | Integer | Global |
| innodb_stats_transient_sample_pages | Integer | Global |
| innodb_status_output | Boolean | Global |
| innodb_status_output_locks | Boolean | Global |
| innodb_strict_mode | Boolean | Both |
| innodb_support_xa | Boolean | Both |
| innodb_sync_spin_loops | Integer | Global |
| innodb_table_locks | Boolean | Both |
| innodb_thread_concurrency | Integer | Global |
| innodb_thread_sleep_delay | Integer | Global |
| innodb_tmpdir | Directory name | Both |
| innodb_trx_purge_view_update_only_debug | Boolean | Global |
| innodb_trx_rseg_n_slots_debug | Integer | Global |
| innodb_undo_log_truncate | Boolean | Global |
| innodb_undo_logs | Integer | Global |
| insert_id | Integer | Session |
| interactive_timeout | Integer | Both |
| internal_tmp_disk_storage_engine | Enumeration | Global |
| join_buffer_size | Integer | Both |
| keep_files_on_create | Boolean | Both |
| key_buffer_size | Integer | Global |
| key_cache_age_threshold | Integer | Global |
| key_cache_block_size | Integer | Global |
| key_cache_division_limit | Integer | Global |
| keyring_aws_cmk_id | String | Global |
| keyring_aws_region | Enumeration | Global |
| keyring_encrypted_file_data | File name | Global |
| keyring_encrypted_file_password | String | Global |
| keyring_file_data | File name | Global |
| keyring_okv_conf_dir | Directory name | Global |
| keyring_operations | Boolean | Global |
| last_insert_id | Integer | Session |
| lc_messages | String | Both |
| lc_time_names | String | Both |
| local_infile | Boolean | Global |
| lock_wait_timeout | Integer | Both |
| log_bin_trust_function_creators | Boolean | Global |
| log_bin_use_v1_row_events | Boolean | Global |
| log_builtin_as_identified_by_password | Boolean | Global |
| log_error_verbosity | Integer | Global |
| log_output | Set | Global |
| log_queries_not_using_indexes | Boolean | Global |
| log_slow_admin_statements | Boolean | Global |
| log_slow_slave_statements | Boolean | Global |
| log_statements_unsafe_for_binlog | Boolean | Global |
| log_syslog | Boolean | Global |
| log_syslog_facility | String | Global |
| log_syslog_include_pid | Boolean | Global |
| log_syslog_tag | String | Global |
| log_throttle_queries_not_using_indexes | Integer | Global |
| log_timestamps | Enumeration | Global |
| log_warnings | Integer | Global |
| long_query_time | Numeric | Both |
| low_priority_updates | Boolean | Both |
| master_info_repository | String | Global |
| master_verify_checksum | Boolean | Global |
| max_allowed_packet | Integer | Both |
| max_binlog_cache_size | Integer | Global |
| max_binlog_size | Integer | Global |
| max_binlog_stmt_cache_size | Integer | Global |
| max_connect_errors | Integer | Global |
| max_connections | Integer | Global |
| max_delayed_threads | Integer | Both |
| max_error_count | Integer | Both |
| max_execution_time | Integer | Both |
| max_heap_table_size | Integer | Both |
| max_insert_delayed_threads | Integer | Both |
| max_join_size | Integer | Both |
| max_length_for_sort_data | Integer | Both |
| max_points_in_geometry | Integer | Both |
| max_prepared_stmt_count | Integer | Global |
| max_relay_log_size | Integer | Global |
| max_seeks_for_key | Integer | Both |
| max_sort_length | Integer | Both |
| max_sp_recursion_depth | Integer | Both |
| max_tmp_tables | Integer | Both |
| max_user_connections | Integer | Both |
| max_write_lock_count | Integer | Global |
| min_examined_row_limit | Integer | Both |
| multi_range_count | Integer | Both |
| myisam_data_pointer_size | Integer | Global |
| myisam_max_sort_file_size | Integer | Global |
| myisam_repair_threads | Integer | Both |
| myisam_sort_buffer_size | Integer | Both |
| myisam_stats_method | Enumeration | Both |
| myisam_use_mmap | Boolean | Global |
| mysql_firewall_mode | Boolean | Global |
| mysql_firewall_trace | Boolean | Global |
| mysql_native_password_proxy_users | Boolean | Global |
| mysqlx_connect_timeout | Integer | Global |
| mysqlx_idle_worker_thread_timeout | Integer | Global |
| mysqlx_max_allowed_packet | Integer | Global |
| mysqlx_max_connections | Integer | Global |
| mysqlx_min_worker_threads | Integer | Global |
| ndb_allow_copying_alter_table | Boolean | Both |
| ndb_autoincrement_prefetch_sz | Integer | Both |
| ndb_batch_size | Integer | Both |
| ndb_blob_read_batch_bytes | Integer | Both |
| ndb_blob_write_batch_bytes | Integer | Both |
| ndb_cache_check_time | Integer | Global |
| ndb_clear_apply_status | Boolean | Global |
| ndb_data_node_neighbour | Integer | Global |
| ndb_default_column_format | Enumeration | Global |
| ndb_default_column_format | Enumeration | Global |
| ndb_deferred_constraints | Integer | Both |
| ndb_deferred_constraints | Integer | Both |
| ndb_distribution | Enumeration | Global |
| ndb_distribution | Enumeration | Global |
| ndb_eventbuffer_free_percent | Integer | Global |
| ndb_eventbuffer_max_alloc | Integer | Global |
| ndb_extra_logging | Integer | Global |
| ndb_force_send | Boolean | Both |
| ndb_fully_replicated | Boolean | Both |
| ndb_index_stat_enable | Boolean | Both |
| ndb_index_stat_option | String | Both |
| ndb_join_pushdown | Boolean | Both |
| ndb_log_binlog_index | Boolean | Global |
| ndb_log_empty_epochs | Boolean | Global |
| ndb_log_empty_epochs | Boolean | Global |
| ndb_log_empty_update | Boolean | Global |
| ndb_log_empty_update | Boolean | Global |
| ndb_log_exclusive_reads | Boolean | Both |
| ndb_log_exclusive_reads | Boolean | Both |
| ndb_log_update_as_write | Boolean | Global |
| ndb_log_update_minimal | Boolean | Global |
| ndb_log_updated_only | Boolean | Global |
| ndb_optimization_delay | Integer | Global |
| ndb_read_backup | Boolean | Global |
| ndb_recv_thread_activation_threshold | Integer | Global |
| ndb_recv_thread_cpu_mask | Bitmap | Global |
| ndb_report_thresh_binlog_epoch_slip | Integer | Global |
| ndb_report_thresh_binlog_mem_usage | Integer | Global |
| ndb_row_checksum | Integer | Both |
| ndb_show_foreign_key_mock_tables | Boolean | Global |
| ndb_slave_conflict_role | Enumeration | Global |
| ndb_table_no_logging | Boolean | Session |
| ndb_table_temporary | Boolean | Session |
| ndb_use_exact_count | Boolean | Both |
| ndb_use_transactions | Boolean | Both |
| ndbinfo_max_bytes | Integer | Both |
| ndbinfo_max_rows | Integer | Both |
| ndbinfo_offline | Boolean | Global |
| ndbinfo_show_hidden | Boolean | Both |
| net_buffer_length | Integer | Both |
| net_read_timeout | Integer | Both |
| net_retry_count | Integer | Both |
| net_write_timeout | Integer | Both |
| new | Boolean | Both |
| offline_mode | Boolean | Global |
| old_alter_table | Boolean | Both |
| old_passwords | Enumeration | Both |
| optimizer_prune_level | Integer | Both |
| optimizer_search_depth | Integer | Both |
| optimizer_switch | Set | Both |
| optimizer_trace | String | Both |
| optimizer_trace_features | String | Both |
| optimizer_trace_limit | Integer | Both |
| optimizer_trace_max_mem_size | Integer | Both |
| optimizer_trace_offset | Integer | Both |
| parser_max_mem_size | Integer | Both |
| performance_schema_show_processlist | Boolean | Global |
| preload_buffer_size | Integer | Both |
| profiling | Boolean | Both |
| profiling_history_size | Integer | Both |
| pseudo_slave_mode | Boolean | Session |
| pseudo_thread_id | Integer | Session |
| query_alloc_block_size | Integer | Both |
| query_cache_limit | Integer | Global |
| query_cache_min_res_unit | Integer | Global |
| query_cache_size | Integer | Global |
| query_cache_type | Enumeration | Both |
| query_cache_wlock_invalidate | Boolean | Both |
| query_prealloc_size | Integer | Both |
| rand_seed1 | Integer | Session |
| rand_seed2 | Integer | Session |
| range_alloc_block_size | Integer | Both |
| range_optimizer_max_mem_size | Integer | Both |
| rbr_exec_mode | Enumeration | Session |
| read_buffer_size | Integer | Both |
| read_only | Boolean | Global |
| read_rnd_buffer_size | Integer | Both |
| relay_log_info_repository | String | Global |
| relay_log_purge | Boolean | Global |
| replication_optimize_for_static_plugin_config | Boolean | Global |
| replication_sender_observe_commit_only | Boolean | Global |
| require_secure_transport | Boolean | Global |
| rewriter_enabled | Boolean | Global |
| rewriter_verbose | Integer | Global |
| rpl_semi_sync_master_enabled | Boolean | Global |
| rpl_semi_sync_master_timeout | Integer | Global |
| rpl_semi_sync_master_trace_level | Integer | Global |
| rpl_semi_sync_master_wait_for_slave_count | Integer | Global |
| rpl_semi_sync_master_wait_no_slave | Boolean | Global |
| rpl_semi_sync_master_wait_point | Enumeration | Global |
| rpl_semi_sync_slave_enabled | Boolean | Global |
| rpl_semi_sync_slave_trace_level | Integer | Global |
| rpl_stop_slave_timeout | Integer | Global |
| secure_auth | Boolean | Global |
| server_id | Integer | Global |
| session_track_gtids | Enumeration | Both |
| session_track_schema | Boolean | Both |
| session_track_state_change | Boolean | Both |
| session_track_system_variables | String | Both |
| session_track_transaction_info | Enumeration | Both |
| sha256_password_proxy_users | Boolean | Global |
| show_compatibility_56 | Boolean | Global |
| show_create_table_verbosity | Boolean | Both |
| show_old_temporals | Boolean | Both |
| slave_allow_batching | Boolean | Global |
| slave_checkpoint_group | Integer | Global |
| slave_checkpoint_period | Integer | Global |
| slave_compressed_protocol | Boolean | Global |
| slave_exec_mode | Enumeration | Global |
| slave_max_allowed_packet | Integer | Global |
| slave_net_timeout | Integer | Global |
| slave_parallel_type | Enumeration | Global |
| slave_parallel_workers | Integer | Global |
| slave_pending_jobs_size_max | Integer | Global |
| slave_preserve_commit_order | Boolean | Global |
| slave_rows_search_algorithms | Set | Global |
| slave_sql_verify_checksum | Boolean | Global |
| slave_transaction_retries | Integer | Global |
| slave_type_conversions | Set | Global |
| slow_launch_time | Integer | Global |
| slow_query_log | Boolean | Global |
| slow_query_log_file | File name | Global |
| sort_buffer_size | Integer | Both |
| sql_auto_is_null | Boolean | Both |
| sql_big_selects | Boolean | Both |
| sql_buffer_result | Boolean | Both |
| sql_log_bin | Boolean | Session |
| sql_log_off | Boolean | Both |
| sql_mode | Set | Both |
| sql_notes | Boolean | Both |
| sql_quote_show_create | Boolean | Both |
| sql_safe_updates | Boolean | Both |
| sql_select_limit | Integer | Both |
| sql_slave_skip_counter | Integer | Global |
| sql_warnings | Boolean | Both |
| stored_program_cache | Integer | Global |
| super_read_only | Boolean | Global |
| sync_binlog | Integer | Global |
| sync_frm | Boolean | Global |
| sync_master_info | Integer | Global |
| sync_relay_log | Integer | Global |
| sync_relay_log_info | Integer | Global |
| table_definition_cache | Integer | Global |
| table_open_cache | Integer | Global |
| thread_cache_size | Integer | Global |
| thread_pool_high_priority_connection | Integer | Both |
| thread_pool_max_unused_threads | Integer | Global |
| thread_pool_prio_kickup_timer | Integer | Global |
| thread_pool_stall_limit | Integer | Global |
| time_zone | String | Both |
| timestamp | Numeric | Session |
| tmp_table_size | Integer | Both |
| transaction_alloc_block_size | Integer | Both |
| transaction_allow_batching | Boolean | Session |
| transaction_isolation | Enumeration | Both |
| transaction_prealloc_size | Integer | Both |
| transaction_read_only | Boolean | Both |
| transaction_write_set_extraction | Enumeration | Both |
| tx_isolation | Enumeration | Both |
| tx_read_only | Boolean | Both |
| unique_checks | Boolean | Both |
| updatable_views_with_limit | Boolean | Both |
| validate_password_check_user_name | Boolean | Global |
| validate_password_dictionary_file | File name | Global |
| validate_password_length | Integer | Global |
| validate_password_mixed_case_count | Integer | Global |
| validate_password_number_count | Integer | Global |
| validate_password_policy | Enumeration | Global |
| validate_password_special_char_count | Integer | Global |
| version_tokens_session | String | Both |

wait_timeout Integer Both

MySQL 5.7 参考手册 / ... / 结构化系统变量

5.1.8.3 结构化系统变量

结构化变量与常规系统变量有两个不同之处:

  • 它的值是一个包含指定被认为密切相关的服务器参数的组件的结构。

  • 给定类型的结构化变量可能有多个实例。每一个都有不同的名称,并指代服务器维护的不同资源。

MySQL 支持一种结构化变量类型,它指定控制键缓存操作的参数。键缓存结构化变量具有以下组件:

本节描述引用结构化变量的语法。键缓存变量用于语法示例,但有关键缓存如何操作的具体细节可以在其他地方找到,即第8.10.2 节"MyISAM 密钥缓存"

要引用结构化变量实例的组成部分,您可以在 *instance_name.component_name*格式中使用复合名称。例子:

language-simple 复制代码
hot_cache.key_buffer_size
hot_cache.key_cache_block_size
cold_cache.key_cache_block_size

default对于每个结构化系统变量,始终预定义 一个名为 的实例。如果引用没有任何实例名称的结构化变量的组件,default则使用该实例。因此, default.key_buffer_sizekey_buffer_size都引用相同的系统变量。

结构化变量实例和组件遵循以下命名规则:

  • 对于给定类型的结构化变量,每个实例都必须具有在该类型的变量中 唯一的名称 。但是,实例名称在结构化变量类型中 不必是唯一的。例如,每个结构化变量都有一个名为 的实例default,因此 default在变量类型之间并不唯一。

  • 每个结构化变量类型的组件名称在所有系统变量名称中必须是唯一的。如果情况并非如此(即,如果两种不同类型的结构化变量可以共享组件成员名称),则不清楚使用哪个默认结构化变量来引用未由实例名称限定的成员名称。

  • 如果结构化变量实例名称作为不带引号的标识符不合法,请使用反引号将其引用为带引号的标识符。例如,hot-cache 不合法,但是hot-cache合法。

  • globalsession、 和 local不是合法的实例名称。 这避免了与引用非结构化系统变量 等符号的冲突 。@@GLOBAL.var_name

目前,前两条规则不可能被违反,因为唯一的结构化变量类型是用于键缓存的类型。如果将来创建其他类型的结构化变量,这些规则可能会具有更大的意义。

除了一个例外,您可以在任何可能出现简单变量名称的上下文中使用复合名称来引用结构化变量组件。例如,您可以使用命令行选项为结构化变量赋值:

language-terminal 复制代码
$> mysqld --hot_cache.key_buffer_size=64K

在选项文件中,使用以下语法:

language-ini 复制代码
[mysqld]
hot_cache.key_buffer_size=64K

如果使用此选项启动服务器,hot_cache除了默认大小为 8MB 的默认密钥缓存之外,它还会创建一个名为 64KB 的密钥缓存。

假设您按如下方式启动服务器:

language-terminal 复制代码
$> mysqld --key_buffer_size=256K \
         --extra_cache.key_buffer_size=128K \
         --extra_cache.key_cache_block_size=2048

在这种情况下,服务器将默认密钥缓存的大小设置为 256KB。(您也可以写为 --default.key_buffer_size=256K。)此外,服务器创建第二个密钥缓存,名为 , extra_cache大小为 128KB,用于缓存表索引块的块缓冲区大小设置为 2048 字节。

以下示例使用三个不同的密钥缓存启动服务器,其大小比例为 3:1:1:

language-terminal 复制代码
$> mysqld --key_buffer_size=6M \
         --hot_cache.key_buffer_size=2M \
         --cold_cache.key_buffer_size=2M

结构化变量值也可以在运行时设置和检索。例如,要将名为 hot_cache10MB 大小的密钥缓存设置为,请使用以下语句之一:

language-sql 复制代码
mysql> SET GLOBAL hot_cache.key_buffer_size = 10*1024*1024;
mysql> SET @@GLOBAL.hot_cache.key_buffer_size = 10*1024*1024;

要检索缓存大小,请执行以下操作:

language-sql 复制代码
mysql> SELECT @@GLOBAL.hot_cache.key_buffer_size;

然而,下面的语句不起作用。LIKE该变量不被解释为复合名称,而是被解释为用于模式匹配操作 的简单字符串 :

language-sql 复制代码
mysql> SHOW GLOBAL VARIABLES LIKE 'hot_cache.key_buffer_size';

这是能够在任何可能出现简单变量名的地方使用结构化变量名的例外情况。

相关推荐
AI慧聚堂8 分钟前
自动化 + 人工智能:投标行业的未来是什么样的?
运维·人工智能·自动化
不爱学英文的码字机器10 分钟前
[Linux] Shell 命令及运行原理
linux·运维·服务器
cdut_suye21 分钟前
Linux工具使用指南:从apt管理、gcc编译到makefile构建与gdb调试
java·linux·运维·服务器·c++·人工智能·python
qq_4336184426 分钟前
shell 编程(三)
linux·运维·服务器
苹果醋333 分钟前
2020重新出发,MySql基础,MySql表数据操作
java·运维·spring boot·mysql·nginx
小蜗牛慢慢爬行35 分钟前
如何在 Spring Boot 微服务中设置和管理多个数据库
java·数据库·spring boot·后端·微服务·架构·hibernate
两张不够花35 分钟前
Jenkins 持续集成部署
运维·jenkins
hanbarger38 分钟前
nosql,Redis,minio,elasticsearch
数据库·redis·nosql
Hacker_xingchen1 小时前
天融信Linux系统安全问题
linux·运维·系统安全