MySQL配置文件模板

彭建业
2023-12-01
MySQL5.7配置文件模板
## MySQL Server Instance Configuration File Template
## ----------------------------------------------------------------------
## Version 1.0.10
##
## <-- Indicates Template comment.  These lines will not be in the output
##
## Replaceable things must be like:
## 
## # [VARIABLE_NAME]="Formula"
## parameter=default value
##
##  For example:
##
##  # [PORT]="port"
##  port=3306
##
## Note - In the example, the formula consists of a variable named 'port' which must be defined before processing.
##
## In addition to the standard max operators (+, -, /, *), the "formula" field supports the following functions:
##
##  rnd(x, y) = Round x to the nearest y
##  max(x, y) = Max value from x, y
##  min(x, y) = Min value from x, y
##
## and named variables.
##
##  For example:
##
##  # [MAX_CONNECTIONS]="max_connections:rnd(max(100,max_connections),1000)"
##  max_connections=
##
## ( Note - Uninitialized variables have a value of 0. )
##
## Finally, there is a special directive named [STATE_CHANGE] that allows for a function to be exectuted at that 
## point during template processing.  
##
##  For example:
## # [STATE_CHANGE]="new_variable : 1"
##
## The following variables must be defined before the formulas are evaluated (otherwise, you get many values set to 0):
##
## memory             - Server Type
##                      Dedicated Server (90% of System Memory), Server (50% of System Memory), All others( rnd(max( 1/12 System Memory, 40*1024*1024), 1024))
## myiasm_percentage  - Table Type
##                      If main InnoDB, set to 5.  Allow userdef.
## active_connections - # Connections.
##                      DSS = 20, OLTP = 500, else user_defined.
## cpus               - Number of CPUS on the machine.
## 
# Other default tuning values
##
## innodb_buffer_pool_size_percentage=2/10
# [STATE_CHANGE]="over_commit_factor:10"
##
##
# MySQL Server Instance Configuration File
# ----------------------------------------------------------------------
# Generated by the MySQL Server Instance Configuration Wizard
#
#
# Installation Instructions
# ----------------------------------------------------------------------
#
# On Linux you can copy this file to /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options
# (@localstatedir@ for this installation) or to
# ~/.my.cnf to set user-specific options.
#
# On Windows you should keep this file in the installation directory 
# of your server (e.g. C:\Program Files\MySQL\MySQL Server X.Y). To
# make sure the server reads the config file use the startup option 
# "--defaults-file". 
#
# To run the server from the command line, execute this in a 
# command line shell, e.g.
# mysqld --defaults-file="C:\Program Files\MySQL\MySQL Server X.Y\my.ini"
#
# To install the server as a Windows service manually, execute this in a 
# command line shell, e.g.
# mysqld --install MySQLXY --defaults-file="C:\Program Files\MySQL\MySQL Server X.Y\my.ini"
#
# And then execute this in a command line shell to start the server, e.g.
# net start MySQLXY
#
#
# Guidelines for editing this file
# ----------------------------------------------------------------------
#
# In this file, you can use all long options that the program supports.
# If you want to know the options a program supports, start the program
# with the "--help" option.
#
# More detailed information about the individual options can also be
# found in the manual.
#
# For advice on how to change settings please see
# https://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
#
#
# CLIENT SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by MySQL client applications.
# Note that only client applications shipped by MySQL are guaranteed
# to read this section. If you want your own MySQL client program to
# honor these values, you need to specify it as an option during the
# MySQL client library initialization.
#
[client]

# [CLIENT_PIPE]=""
# pipe=

# [CLIENT_SOCKET]="socket"
# socket=

# [CLIENT_PORT]="port"
port=3306

[mysql]
no-beep

# [CLIENT_DEFAULT_CHARACTER_SET]=""
# default-character-set=


# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this 
# file.
#
# [SERVER_TYPE]="server_type"
# server_type=
[mysqld]

# The next three options are mutually exclusive to SERVER_PORT below.
# [SERVER_SKIP]=""
# skip-networking=
# [SERVER_PIPE]=""
# enable-named-pipe=
# [SHARED_MEMORY]=""
# shared-memory=

# [SHARED_MEMORY_BASE_NAME]="shared_memory_base_name"
# shared-memory-base-name=

# The Pipe the MySQL Server will use
# [SERVER_SOCKET]="socket"
# socket=

# The TCP/IP Port the MySQL Server will listen on
# [SERVER_PORT]="port"
port=3306

# Path to installation directory. All paths are usually resolved relative to this.
# [BASE_DIR]="basedir"
# basedir=

# Path to the database root
# [DATA_DIR]="datadir"
datadir=

# The default character set that will be used when a new schema or table is
# created and no character set is defined
# [SERVER_DEFAULT_CHARACTER_SET]=""
# character-set-server=

# The default storage engine that will be used when create new tables when
# [DEFAULT_STORAGE_ENGINE]="default_storage_engine"
default-storage-engine=

# Set the SQL mode to strict
# [SQL_MODE]=""
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

# General and Slow logging.
# [LOG_OUT]="log_out"
log-output=

# [GEN_QUERY]="gen_query"
general-log=

# [GEN_QUERY_FILE]="gen_query_file"
general_log_file=

# [SLOW_QUERY]="slow_query"
slow-query-log=

# [SLOW_QUERY_FILE]="slow_query_file"
slow_query_log_file=

# [LONG_QUERY]="long_query_time"
long_query_time=

# Error Logging.
# [LOG_ERR]="log_error"
log-error=

# ***** Group Replication Related *****
# Specifies the base name to use for binary log files. With binary logging
# enabled, the server logs all statements that change data to the binary
# log, which is used for backup and replication.
# [LOG_BIN]="log_bin"
log-bin=

# ***** Group Replication Related *****
# Sets the binary logging format, and can be any one of STATEMENT, ROW,
# or MIXED. ROW is suggested for Group Replication.
# [BINLOG_FORMAT]="binlog_format"
# binlog_format=

# ***** Group Replication Related *****
# Causes the master to write a checksum for each event in the binary log.
# binlog_checksum supports the values NONE (disabled) and CRC32.
# The default is CRC32. When disabled (value NONE), the server verifies
# that it is writing only complete events to the binary log by writing
# and checking the event length (rather than a checksum) for each event.
# NONE must be used with Group Replication.
# [BINLOG_CHECKSUM]="binlog_checksum"
# binlog_checksum=

# ***** Group Replication Related *****
# The base name for the relay log. The server creates relay log files in
# sequence by adding a numeric suffix to the base name. If you specify this
# option, the value specified is also used as the base name for the relay log
# index file. Relay logs increase speed by using load-balancing between disks.
# [RELAY_LOG]="relay_log"
# relay_log=

# ***** Group Replication Related *****
# Specifies the server ID. For servers that are used in a replication topology,
# you must specify a unique server ID for each replication server, in the
# range from 1 to 2^32 − 1. “Unique” means that each ID must be different
# from every other ID in use by any other replication master or slave.
# [SERVER_ID]="server_id"
server-id=
# ***** Group Replication Related *****
# The host name or IP address of the slave to be reported to the master
# during slave registration. This value appears in the output of SHOW SLAVE HOSTS
# on the master server. Leave the value unset if you do not want the slave to
# register itself with the master.
# [REPORT_HOST]="report_host"
# report_host=

# ***** Group Replication Related *****
# The TCP/IP port number for connecting to the slave, to be reported to the master during
# slave registration. Set this only if the slave is listening on a nondefault port or if
# you have a special tunnel from the master or other clients to the slave.
# [REPORT_PORT]="report_port"
# report_port=

# ***** Group Replication Related *****
# This option specifies whether global transaction identifiers (GTIDs) are
# used to identify transactions. ON must be used with Group Replication.
# [GTID_MODE]="gtid_mode"
# gtid_mode=

# ***** Group Replication Related *****
# When enabled, the server enforces GTID consistency by allowing execution of
# only statements that can be safely logged using a GTID. You must set this
# option to ON before enabling GTID based replication.
# [ENFORCE_GTID_CONSISTENCY]="enforce_gtid_consistency"
# enforce_gtid_consistency=

# ***** Group Replication Related *****
# Whether updates received by a slave server from a master server should be
# logged to the slave's own binary log. Binary logging must be enabled on
# the slave for this variable to have any effect. ON must be used with
# Group Replication.
# [LOG_SLAVE_UPDATES]="log_slave_updates"
# log_slave_updates=

# ***** Group Replication Related *****
# Determines whether the slave server logs master status and connection information
# to an InnoDB table in the mysql database, or to a file in the data directory.
# The TABLE setting is required when multiple replication channels are configured.
# [MASTER_INFO_REPOSITORY]="master_info_repository"
# master_info_repository=

# ***** Group Replication Related *****
# Determines whether the slave server logs its position in the relay logs to an InnoDB
# table in the mysql database, or to a file in the data directory. The TABLE setting is
# required when multiple replication channels are configured.
# [RELAY_LOG_INFO_REPOSITORY]="relay_log_info_repository"
# relay_log_info_repository=

# ***** Group Replication Related *****
# Defines the algorithm used to hash the writes extracted during a transaction. If you
# are using Group Replication, this variable must be set to XXHASH64 because the process
# of extracting the writes from a transaction is required for conflict detection on all
# group members.
# [TRANSACTION_WRITE_SET_EXTRACTION]="transaction_write_set_extraction"
# transaction_write_set_extraction=
# [LOWER_CASE_TABLE_NAMES]="lower_case_table_names"
lower_case_table_names=

# Secure File Priv.
# [SECURE_FILE_PRIV]="secure_file_priv"
# secure-file-priv=

# The maximum amount of concurrent sessions the MySQL server will
# allow. One of these connections will be reserved for a user with
# SUPER privileges to allow the administrator to login even if the
# connection limit has been reached.
# [STATE_CHANGE]="max_connections:rnd(min(active_connections*15/10+10,memory/512K),1000)"
# [MAX_CONNECTIONS]="max_connections:rnd(max(151,max_connections),1000)"
max_connections=

# The number of open tables for all threads. Increasing this value
# increases the number of file descriptors that mysqld requires.
# Therefore you have to make sure to set the amount of open files
# allowed to at least 4096 in the variable "open-files-limit" in
# section [mysqld_safe]
# [STATE_CHANGE]="available_memory:max(0,memory-(max_connections*256K))"
# [STATE_CHANGE]="buffers_memory:available_memory*7/10"
# [STATE_CHANGE]="thread_buffers_memory:available_memory*3/10"
# [STATE_CHANGE]="memory_per_thread:thread_buffers_memory*over_commit_factor/max_connections"
# [TABLE_OPEN_CACHE]="table_open_cache:2000"
table_open_cache=

# Maximum size for internal (in-memory) temporary tables. If a table
# grows larger than this value, it is automatically converted to disk
# based table This limitation is for a single table. There can be many
# of them.
# [STATE_CHANGE]="buffers_memory:buffers_memory-table_open_cache*8K"
# [STATE_CHANGE]="big_thread_buffers:memory_per_thread*over_commit_factor"
# [STATE_CHANGE]="tmp_table_size:max(16M,big_thread_buffers)"
# [TMP_TABLE_SIZE]="tmp_table_size:min(tmp_table_size,memory*1/10)","USE_BYTES"
tmp_table_size=

# How many threads we should keep in a cache for reuse. When a client
# disconnects, the client's threads are put in the cache if there aren't
# more than thread_cache_size threads from before.  This greatly reduces
# the amount of thread creations needed if you have a lot of new
# connections. (Normally this doesn't give a notable performance
# improvement if you have a good thread implementation.)
# [THREAD_CACHE_SIZE]="thread_cache_size:min(100,(rnd(max_connections/100,1)+8))"
thread_cache_size=

#*** MyISAM Specific options
# The maximum size of the temporary file MySQL is allowed to use while
# recreating the index (during REPAIR, ALTER TABLE or LOAD DATA INFILE.
# If the file-size would be bigger than this, the index will be created
# through the key cache (which is slower).
myisam_max_sort_file_size=100G

# If the temporary file used for fast index creation would be bigger
# than using the key cache by the amount specified here, then prefer the
# key cache method.  This is mainly used to force long character keys in
# large tables to use the slower key cache method to create the index.
# [STATE_CHANGE]="myisam_sort_buffer_size:max(8M,big_thread_buffers)"
# [MYISAM_SORT_BUFFER_SIZE]="myisam_sort_buffer_size:min(myisam_sort_buffer_size,memory*2/10)","USE_BYTES"
myisam_sort_buffer_size=

# Size of the Key Buffer, used to cache index blocks for MyISAM tables.
# Do not set it larger than 30% of your available memory, as some memory
# is also required by the OS to cache rows. Even if you're not using
# MyISAM tables, you should still set it to 8-64M as it will also be
# used for internal temporary disk tables.
# [STATE_CHANGE]="myisam_buffers:buffers_memory*(myisam_percentage/100)"
# [KEY_BUFFER_SIZE]="key_buffer_size:max(8M,myisam_buffers/2)","USE_BYTES"
key_buffer_size=

# Size of the buffer used for doing full table scans of MyISAM tables.
# Allocated per thread, if a full scan is needed.
# [STATE_CHANGE]="read_buffer_size:min(64K,memory_per_thread*2/100)"
# [READ_BUFFER_SIZE]="read_buffer_size:min(read_buffer_size,memory/100)","USE_BYTES"
read_buffer_size=

# [STATE_CHANGE]="read_rnd_buffer_size:min(256K,memory_per_thread*4/10)"
# [READ_RND_BUFFER_SIZE]="read_rnd_buffer_size:min(read_rnd_buffer_size,memory*4/100)","USE_BYTES"
read_rnd_buffer_size=

#*** INNODB Specific options ***
# [INNODB_HOME]=""
# innodb_data_home_dir=

# Use this option if you have a MySQL server with InnoDB support enabled
# but you do not plan to use it. This will save memory and disk space
# and speed up some things.
# [SKIP_INNODB]
# skip-innodb

# If set to 1, InnoDB will flush (fsync) the transaction logs to the
# disk at each commit, which offers full ACID behavior. If you are
# willing to compromise this safety, and you are running small
# transactions, you may set this to 0 or 2 to reduce disk I/O to the
# logs. Value 0 means that the log is only written to the log file and
# the log file flushed to disk approximately once per second. Value 2
# means the log is written to the log file at each commit, but the log
# file is only flushed to disk approximately once per second.
innodb_flush_log_at_trx_commit=1

# The size of the buffer InnoDB uses for buffering log data. As soon as
# it is full, InnoDB will have to flush it to disk. As it is flushed
# once per second anyway, it does not make sense to have it very large
# (even with long transactions).
# [STATE_CHANGE]="innodb_buffers:max(innodb_buffers-innodb_additional_mem_pool_size,0)"
# [STATE_CHANGE]="innodb_log_buffer_size:max(1M,innodb_buffers/100)"
# [INNODB_LOG_BUFFER_SIZE]="innodb_log_buffer_size:min(16M,innodb_log_buffer_size)","USE_BYTES"
innodb_log_buffer_size=

# InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and
# row data. The bigger you set this the less disk I/O is needed to
# access data in tables. On a dedicated database server you may set this
# parameter up to 80% of the machine physical memory size. Do not set it
# too large, though, because competition of the physical memory may
# cause paging in the operating system.  Note that on 32bit systems you
# might be limited to 2-3.5G of user level memory per process, so do not
# set it too high.
# [INNODB_BUFFER_POOL_SIZE]="innodb_buffer_pool_size:max(innodb_buffers-innodb_log_buffer_size,8M)","USE_BYTES"
innodb_buffer_pool_size=

# Size of each log file in a log group. You should set the combined size
# of log files to about 25%-100% of your buffer pool size to avoid
# unneeded buffer pool flush activity on log file overwrite. However,
# note that a larger logfile size will increase the time needed for the
# recovery process.
# [INNODB_LOG_FILE_SIZE]="innodb_log_file_size:48M","USE_BYTES"
innodb_log_file_size=

# Number of threads allowed inside the InnoDB kernel. The optimal value
# depends highly on the application, hardware as well as the OS
# scheduler properties. A too high value may lead to thread thrashing.
## originally formula was innodb_thread_concurrency=<<{:M=8,2*([CPUS]+[DISKS])}>>
## but since only one disk will be used in a standard configuration
## [DISKS] is replaced by 1
# [INNODB_THREAD_CONCURRENCY]="innodb_thread_concurrency:max(8,2*cpus+1)"
innodb_thread_concurrency=

# The increment size (in MB) for extending the size of an auto-extend InnoDB system tablespace file when it becomes full.
# [INNODB_AUTOEXTEND_INCREMENT]="innodb_autoextend_increment:64"
innodb_autoextend_increment=

# The number of regions that the InnoDB buffer pool is divided into.
# For systems with buffer pools in the multi-gigabyte range, dividing the buffer pool into separate instances can improve concurrency,
# by reducing contention as different threads read and write to cached pages.
# [STATE_CHANGE]="innodb_buffer_pool_instances:rnd(innodb_buffer_pool_size/134217728,1)"
# [INNODB_BUFFER_POOL_INSTANCES]="innodb_buffer_pool_instances:max((innodb_buffer_pool_instances*bitedness), 8)"
innodb_buffer_pool_instances=

# Determines the number of threads that can enter InnoDB concurrently.
# [INNODB_CONCURRENCY_TICKETS]="innodb_concurrency_tickets:5000"
innodb_concurrency_tickets=

# Specifies how long in milliseconds (ms) a block inserted into the old sublist must stay there after its first access before
# it can be moved to the new sublist.
# [INNODB_OLD_BLOCKS_TIME]="innodb_old_blocks_time:1000"
innodb_old_blocks_time=

# It specifies the maximum number of .ibd files that MySQL can keep open at one time. The minimum value is 10.
# [INNODB_OPEN_FILES]="innodb_open_files:max(300,(table_open_cache*innodb_file_per_table))"
innodb_open_files=

# When this variable is enabled, InnoDB updates statistics during metadata statements.
# [INNODB_STATS_ON_METADATA]="innodb_stats_on_metadata:0"
innodb_stats_on_metadata=

# When innodb_file_per_table is enabled (the default in 5.6.6 and higher), InnoDB stores the data and indexes for each newly created table
# in a separate .ibd file, rather than in the system tablespace.
# [INNODB_FILE_PER_TABLE]="innodb_file_per_table:1"
innodb_file_per_table=

# Use the following list of values: 0 for crc32, 1 for strict_crc32, 2 for innodb, 3 for strict_innodb, 4 for none, 5 for strict_none.
# [INNODB_CHECKSUM_ALGORITHM]="innodb_checksum_algorithm:0"
innodb_checksum_algorithm=

# The number of outstanding connection requests MySQL can have.
# This option is useful when the main MySQL thread gets many connection requests in a very short time.
# It then takes some time (although very little) for the main thread to check the connection and start a new thread.
# The back_log value indicates how many requests can be stacked during this short time before MySQL momentarily
# stops answering new requests.
# You need to increase this only if you expect a large number of connections in a short period of time.
# [BACK_LOG]="back_log:min(900,(rnd(max_connections/5,1)+50))"
back_log=

# If this is set to a nonzero value, all tables are closed every flush_time seconds to free up resources and
# synchronize unflushed data to disk.
# This option is best used only on systems with minimal resources.
# [FLUSH_TIME]="flush_time:0"
flush_time=

# The minimum size of the buffer that is used for plain index scans, range index scans, and joins that do not use
# indexes and thus perform full table scans.
# [JOIN_BUFFER_SIZE]="join_buffer_size:256K","USE_BYTES"
join_buffer_size=

# The maximum size of one packet or any generated or intermediate string, or any parameter sent by the
# mysql_stmt_send_long_data() C API function.
# [MAX_ALLOWED_PACKET]="max_allowed_packet:4M","USE_BYTES"
max_allowed_packet=

# If more than this many successive connection requests from a host are interrupted without a successful connection,
# the server blocks that host from performing further connections.
# [MAX_CONNECT_ERRORS]="max_connect_errors:100"
max_connect_errors=

# Changes the number of file descriptors available to mysqld.
# You should try increasing the value of this option if mysqld gives you the error "Too many open files".
# [OPEN_FILES_LIMIT]="open_files_limit:10+max_connections+table_open_cache*2"
open_files_limit=

# If you see many sort_merge_passes per second in SHOW GLOBAL STATUS output, you can consider increasing the
# sort_buffer_size value to speed up ORDER BY or GROUP BY operations that cannot be improved with query optimization
# or improved indexing.
# [SORT_BUFFER_SIZE]="sort_buffer_size:256K","USE_BYTES"
sort_buffer_size=

# The number of table definitions (from .frm files) that can be stored in the definition cache.
# If you use a large number of tables, you can create a large table definition cache to speed up opening of tables.
# The table definition cache takes less space and does not use file descriptors, unlike the normal table cache.
# The minimum and default values are both 400.
# [TABLE_DEFINITION_CACHE]="table_definition_cache:min(2000,(rnd(table_open_cache/2,1)+400))"
table_definition_cache=

# Specify the maximum size of a row-based binary log event, in bytes.
# Rows are grouped into events smaller than this size if possible. The value should be a multiple of 256.
# [BINLOG_ROW_EVENT_MAX_SIZE]="binlog_row_event_max_size:8192","USE_BYTES"
binlog_row_event_max_size=

# If the value of this variable is greater than 0, a replication slave synchronizes its master.info file to disk.
# (using fdatasync()) after every sync_master_info events.
# [SYNC_MASTER_INFO]="sync_master_info:10000"
sync_master_info=

# If the value of this variable is greater than 0, the MySQL server synchronizes its relay log to disk.
# (using fdatasync()) after every sync_relay_log writes to the relay log.
# [SYNC_RELAY_LOG]="sync_relay_log:10000"
sync_relay_log=

# If the value of this variable is greater than 0, a replication slave synchronizes its relay-log.info file to disk.
# (using fdatasync()) after every sync_relay_log_info transactions.
# [SYNC_RELAY_LOG_INFO]="sync_relay_log_info:10000"
sync_relay_log_info=

# Load mysql plugins at start."plugin_x ; plugin_y".
# [PLUGIN_LOAD]="plugin_load"
plugin_load=

# The TCP/IP Port the MySQL Server X Protocol will listen on.
# [LOOSE_MYSQLX_PORT]="loose_mysqlx_port"
loose_mysqlx_port=

 类似资料: