MySQL常见的配置参数概览

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
云数据库 RDS PostgreSQL,高可用系列 2核4GB
简介: 一、MySQL常见的配置参数有400+项,其中DBA常用的配置参数大概可以分为如下几种: ①、各种buffer:缓冲各种配置参数 ②、各种cache:缓存各种配置参数 ③、各种log:日志相关配置参数 ④、各种file:文件相关配置参数 ⑤、各种max:各种最大值配置参数 二、在MySQL中输入命令 show global variablesG;可以查看配置参数的明细。

一、MySQL常见的配置参数有400+项,其中DBA常用的配置参数大概可以分为如下几种:

①、各种buffer:缓冲各种配置参数
②、各种cache:缓存各种配置参数
③、各种log:日志相关配置参数
④、各种file:文件相关配置参数
⑤、各种max:各种最大值配置参数

二、在MySQL中输入命令 show global variablesG;可以查看配置参数的明细。如下为结尾部分:

mysql> show global variables\G

省略部分内容

*************************** 435. row ***************************
Variable_name: version
        Value: 5.6.36
*************************** 436. row ***************************
Variable_name: version_comment
        Value: MySQL Community Server (GPL)
*************************** 437. row ***************************
Variable_name: version_compile_machine
        Value: x86_64
*************************** 438. row ***************************
Variable_name: version_compile_os
        Value: linux-glibc2.5
*************************** 439. row ***************************
Variable_name: wait_timeout
        Value: 28800
439 rows in set (0.11 sec)

三、各种buffer相关配置参数

mysql> show global variables like "%buffer%";
+-------------------------------------+----------------+
| Variable_name                       | Value          |
+-------------------------------------+----------------+
| bulk_insert_buffer_size             | 8388608        |
| innodb_buffer_pool_dump_at_shutdown | OFF            |
| innodb_buffer_pool_dump_now         | OFF            |
| innodb_buffer_pool_filename         | ib_buffer_pool |
| innodb_buffer_pool_instances        | 8              |
| innodb_buffer_pool_load_abort       | OFF            |
| innodb_buffer_pool_load_at_startup  | OFF            |
| innodb_buffer_pool_load_now         | OFF            |
| innodb_buffer_pool_size             | 134217728      | 相当于128M
| innodb_change_buffer_max_size       | 25             |
| innodb_change_buffering             | all            |
| innodb_log_buffer_size              | 8388608        |
| innodb_sort_buffer_size             | 1048576        |
| join_buffer_size                    | 262144         |
| key_buffer_size                     | 8388608        |
| myisam_sort_buffer_size             | 8388608        |
| net_buffer_length                   | 16384          |
| preload_buffer_size                 | 32768          |
| read_buffer_size                    | 131072         |
| read_rnd_buffer_size                | 262144         |
| sort_buffer_size                    | 262144         |
| sql_buffer_result                   | OFF            |
+-------------------------------------+----------------+
22 rows in set (0.00 sec)

参数说明:

①、innodb_buffer_pool_size:缓冲池字节大小(建议为物理内存的75%)
默认为128M,MySQL中以KB为单位显示。

②、innodb_log_buffer_size:为尚未执行的日志写入事务分配的缓存(起到I/O加速的作用)

四、各种cache相关配置参数

mysql> show global variables like "%cache%";
+--------------------------------+----------------------+
| Variable_name                  | Value                |
+--------------------------------+----------------------+
| binlog_cache_size              | 32768                |
| binlog_stmt_cache_size         | 32768                |
| have_query_cache               | YES                  |
| host_cache_size                | 279                  |
| innodb_disable_sort_file_cache | OFF                  |
| innodb_ft_cache_size           | 8000000              |
| innodb_ft_result_cache_limit   | 2000000000           |
| innodb_ft_total_cache_size     | 640000000            |
| key_cache_age_threshold        | 300                  |
| key_cache_block_size           | 1024                 |
| key_cache_division_limit       | 100                  |
| max_binlog_cache_size          | 18446744073709547520 |
| max_binlog_stmt_cache_size     | 18446744073709547520 |
| metadata_locks_cache_size      | 1024                 |
| query_cache_limit              | 1048576              |
| query_cache_min_res_unit       | 4096                 |
| query_cache_size               | 1048576              |
| query_cache_type               | OFF                  |
| query_cache_wlock_invalidate   | OFF                  |
| stored_program_cache           | 256                  |
| table_definition_cache         | 1400                 |
| table_open_cache               | 2000                 |
| table_open_cache_instances     | 1                    |
| thread_cache_size              | 9                    |
+--------------------------------+----------------------+
24 rows in set (0.00 sec)

五、各种log相关配置参数

mysql> show global variables like "%log%";
+-----------------------------------------+-----------------------------+
| Variable_name                           | Value                       |
+-----------------------------------------+-----------------------------+
| back_log                                | 80                          |
| binlog_cache_size                       | 32768                       |
| binlog_checksum                         | CRC32                       |
| binlog_direct_non_transactional_updates | OFF                         |
| binlog_error_action                     | IGNORE_ERROR                |
| binlog_format                           | STATEMENT                   |
| binlog_gtid_simple_recovery             | OFF                         |
| binlog_max_flush_queue_time             | 0                           |
| binlog_order_commits                    | ON                          |
| binlog_row_image                        | FULL                        |
| binlog_rows_query_log_events            | OFF                         |
| binlog_stmt_cache_size                  | 32768                       |
| binlogging_impossible_mode              | IGNORE_ERROR                |
| expire_logs_days                        | 0                           |
| general_log                             | OFF                         |
| general_log_file                        | /data/mysql/JSH-01.log      |
| innodb_api_enable_binlog                | OFF                         |
| innodb_flush_log_at_timeout             | 1                           |
| innodb_flush_log_at_trx_commit          | 1                           |
| innodb_locks_unsafe_for_binlog          | OFF                         |
| innodb_log_buffer_size                  | 8388608                     |
| innodb_log_compressed_pages             | ON                          |
| innodb_log_file_size                    | 50331648                    |
| innodb_log_files_in_group               | 2                           |
| innodb_log_group_home_dir               | ./                          |
| innodb_mirrored_log_groups              | 1                           |
| innodb_online_alter_log_max_size        | 134217728                   |
| innodb_undo_logs                        | 128                         |
| log_bin                                 | OFF                         |
| log_bin_basename                        |                             |
| log_bin_index                           |                             |
| log_bin_trust_function_creators         | OFF                         |
| log_bin_use_v1_row_events               | OFF                         |
| log_error                               | /data/mysql/JSH-01.err      |
| log_output                              | FILE                        |
| log_queries_not_using_indexes           | OFF                         |
| log_slave_updates                       | OFF                         |
| log_slow_admin_statements               | OFF                         |
| log_slow_slave_statements               | OFF                         |
| log_throttle_queries_not_using_indexes  | 0                           |
| log_warnings                            | 1                           |
| max_binlog_cache_size                   | 18446744073709547520        |
| max_binlog_size                         | 1073741824                  |
| max_binlog_stmt_cache_size              | 18446744073709547520        |
| max_relay_log_size                      | 0                           |
| relay_log                               |                             |
| relay_log_basename                      |                             |
| relay_log_index                         |                             |
| relay_log_info_file                     | relay-log.info              |
| relay_log_info_repository               | FILE                        |
| relay_log_purge                         | ON                          |
| relay_log_recovery                      | OFF                         |
| relay_log_space_limit                   | 0                           |
| simplified_binlog_gtid_recovery         | OFF                         |
| slow_query_log                          | OFF                         |
| slow_query_log_file                     | /data/mysql/JSH-01-slow.log |
| sql_log_bin                             | ON                          |
| sql_log_off                             | OFF                         |
| sync_binlog                             | 0                           |
| sync_relay_log                          | 10000                       |
| sync_relay_log_info                     | 10000                       |
+-----------------------------------------+-----------------------------+
61 rows in set (0.00 sec)

六、各种file相关配置参数

mysql> show global variables like "%file%";
+---------------------------------------+-----------------------------+
| Variable_name                         | Value                       |
+---------------------------------------+-----------------------------+
| character_set_filesystem              | binary                      |
| core_file                             | OFF                         |
| ft_stopword_file                      | (built-in)                  |
| general_log_file                      | /data/mysql/JSH-01.log      |
| init_file                             |                             |
| innodb_buffer_pool_filename           | ib_buffer_pool              |
| innodb_data_file_path                 | ibdata1:12M:autoextend      |
| innodb_disable_sort_file_cache        | OFF                         |
| innodb_file_format                    | Antelope                    |
| innodb_file_format_check              | ON                          |
| innodb_file_format_max                | Antelope                    |
| innodb_file_per_table                 | ON                          |
| innodb_log_file_size                  | 50331648                    |
| innodb_log_files_in_group             | 2                           |
| innodb_open_files                     | 2000                        |
| keep_files_on_create                  | OFF                         |
| large_files_support                   | ON                          |
| local_infile                          | ON                          |
| lower_case_file_system                | OFF                         |
| myisam_max_sort_file_size             | 9223372036853727232         |
| open_files_limit                      | 65535                       |
| performance_schema_max_file_classes   | 50                          |
| performance_schema_max_file_handles   | 32768                       |
| performance_schema_max_file_instances | 7693                        |
| pid_file                              | /data/mysql/JSH-01.pid      |
| relay_log_info_file                   | relay-log.info              |
| secure_file_priv                      | NULL                        |
| slow_query_log_file                   | /data/mysql/JSH-01-slow.log |
+---------------------------------------+-----------------------------+
28 rows in set (0.00 sec)

七、各种max相关配置参数

mysql> show global variables like "%max%";
+------------------------------------------+----------------------+
| Variable_name                            | Value                |
+------------------------------------------+----------------------+
| binlog_max_flush_queue_time              | 0                    |
| ft_max_word_len                          | 84                   |
| group_concat_max_len                     | 1024                 |
| innodb_adaptive_max_sleep_delay          | 150000               |
| innodb_change_buffer_max_size            | 25                   |
| innodb_compression_pad_pct_max           | 50                   |
| innodb_file_format_max                   | Antelope             |
| innodb_ft_max_token_size                 | 84                   |
| innodb_io_capacity_max                   | 2000                 |
| innodb_max_dirty_pages_pct               | 75                   |
| innodb_max_dirty_pages_pct_lwm           | 0                    |
| innodb_max_purge_lag                     | 0                    |
| innodb_max_purge_lag_delay               | 0                    |
| innodb_online_alter_log_max_size         | 134217728            |
| max_allowed_packet                       | 4194304              |
| max_binlog_cache_size                    | 18446744073709547520 |
| max_binlog_size                          | 1073741824           |
| max_binlog_stmt_cache_size               | 18446744073709547520 |
| max_connect_errors                       | 100                  |
| max_connections                          | 151                  |
| max_delayed_threads                      | 20                   |
| max_digest_length                        | 1024                 |
| max_error_count                          | 64                   |
| max_heap_table_size                      | 16777216             |
| max_insert_delayed_threads               | 20                   |
| max_join_size                            | 18446744073709551615 |
| max_length_for_sort_data                 | 1024                 |
| max_prepared_stmt_count                  | 16382                |
| max_relay_log_size                       | 0                    |
| max_seeks_for_key                        | 18446744073709551615 |
| max_sort_length                          | 1024                 |
| max_sp_recursion_depth                   | 0                    |
| max_tmp_tables                           | 32                   |
| max_user_connections                     | 0                    |
| max_write_lock_count                     | 18446744073709551615 |
| myisam_max_sort_file_size                | 9223372036853727232  |
| optimizer_trace_max_mem_size             | 16384                |
| performance_schema_max_cond_classes      | 80                   |
| performance_schema_max_cond_instances    | 3504                 |
| performance_schema_max_digest_length     | 1024                 |
| performance_schema_max_file_classes      | 50                   |
| performance_schema_max_file_handles      | 32768                |
| performance_schema_max_file_instances    | 7693                 |
| performance_schema_max_mutex_classes     | 200                  |
| performance_schema_max_mutex_instances   | 15906                |
| performance_schema_max_rwlock_classes    | 40                   |
| performance_schema_max_rwlock_instances  | 9102                 |
| performance_schema_max_socket_classes    | 10                   |
| performance_schema_max_socket_instances  | 322                  |
| performance_schema_max_stage_classes     | 150                  |
| performance_schema_max_statement_classes | 168                  |
| performance_schema_max_table_handles     | 4000                 |
| performance_schema_max_table_instances   | 12500                |
| performance_schema_max_thread_classes    | 50                   |
| performance_schema_max_thread_instances  | 402                  |
| slave_max_allowed_packet                 | 1073741824           |
| slave_pending_jobs_size_max              | 16777216             |
+------------------------------------------+----------------------+
57 rows in set (0.00 sec)
相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。   相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情: https://www.aliyun.com/product/rds/mysql 
相关文章
|
27天前
|
存储 缓存 监控
MySQL服务器配置优化:my.cnf参数调优指南
本文深入解析了MySQL核心配置参数及性能优化技巧,涵盖内存结构、调优原则、存储引擎优化、查询性能优化等内容,通过实战案例帮助读者构建高性能MySQL服务器配置,解决常见的性能瓶颈问题。
|
13天前
|
Ubuntu 安全 关系型数据库
安装与配置MySQL 8 on Ubuntu,包括权限授予、数据库备份及远程连接指南
以上步骤提供了在Ubuntu上从头开始设置、配置、授权、备份及恢复一个基础但完整的MySQL环境所需知识点。
188 7
|
6月前
|
关系型数据库 MySQL Java
【YashanDB知识库】原生mysql驱动配置连接崖山数据库
【YashanDB知识库】原生mysql驱动配置连接崖山数据库
【YashanDB知识库】原生mysql驱动配置连接崖山数据库
|
4月前
|
关系型数据库 MySQL Java
安装和配置JDK、Tomcat、MySQL环境,以及如何在Linux下更改后端端口。
遵循这些步骤,你可以顺利完成JDK、Tomcat、MySQL环境的安装和配置,并在Linux下更改后端端口。祝你顺利!
353 11
|
5月前
|
Ubuntu 关系型数据库 MySQL
在Ubuntu 22.04上配置和安装MySQL
以上就是在Ubuntu 22.04上配置和安装MySQL的步骤。这个过程可能看起来有点复杂,但只要按照步骤一步步来,你会发现其实并不难。记住,任何时候都不要急于求成,耐心是解决问题的关键。
647 30
|
5月前
|
关系型数据库 MySQL Linux
CentOS 7系统下详细安装MySQL 5.7的步骤:包括密码配置、字符集配置、远程连接配置
以上就是在CentOS 7系统下安装MySQL 5.7的详细步骤。希望这个指南能帮助你顺利完成安装。
1455 26
|
11月前
|
SQL 关系型数据库 MySQL
mysql主从复制概述和配置
【10月更文挑战第22天】MySQL 主从复制是一种将主服务器的数据复制到一个或多个从服务器的技术,实现读写分离,提高系统性能和可用性。主服务器记录变更日志,从服务器通过 I/O 和 SQL 线程读取并应用这些变更。适用于读写分离、数据备份和恢复、数据分析等场景。配置步骤包括修改配置文件、创建复制用户、配置从服务器连接主服务器并启动复制进程。
367 1
|
6月前
|
SQL 关系型数据库 MySQL
seatunnel配置mysql2hive
本文介绍了SeaTunnel的安装与使用教程,涵盖从安装、配置到数据同步的全过程。主要内容包括: 1. **SeaTunnel安装**:详细描述了下载、解压及配置连接器等步骤。 2. **模拟数据到Hive (fake2hive)**:通过编辑测试脚本,将模拟数据写入Hive表。 3. **MySQL到控制台 (mysql2console)**:创建配置文件并执行命令,将MySQL数据输出到控制台。 4. **MySQL到Hive (mysql2hive)**:创建Hive表,配置并启动同步任务,支持单表和多表同步。
|
5月前
|
存储 Oracle 关系型数据库
MySQL 8.4 配置SSL组复制(八个步骤)
MySQL 8.4 配置SSL组复制(八个步骤)
319 0
|
9月前
|
SQL 存储 关系型数据库
MySQL进阶突击系列(01)一条简单SQL搞懂MySQL架构原理 | 含实用命令参数集
本文从MySQL的架构原理出发,详细介绍其SQL查询的全过程,涵盖客户端发起SQL查询、服务端SQL接口、解析器、优化器、存储引擎及日志数据等内容。同时提供了MySQL常用的管理命令参数集,帮助读者深入了解MySQL的技术细节和优化方法。

推荐镜像

更多