MySQL配置文件

发布时间 2023-09-26 11:14:46作者: 小维江湖

/etc/my.cnf

默认配置

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

手动修改后的配置

[client]
port = 3306
socket = /tmp/mysql.sock
 
[mysqld]
user = mysql
port = 3306
#basedir = /opt/mysql
datadir = /data/mysql_data
socket = /tmp/mysql.sock
pid-file = mysql.pid
character-set-server = utf8mb4
skip_name_resolve = 1
open_files_limit = 65535
back_log = 1024
max_connections = 1000
max_connect_errors = 1000000
table_open_cache = 1024
table_definition_cache = 1024
table_open_cache_instances = 64
thread_stack = 512K
external-locking = FALSE
max_allowed_packet = 128M
sort_buffer_size = 2M
join_buffer_size = 2M
thread_cache_size = 500
query_cache_size = 0
query_cache_type = 0
interactive_timeout = 3600
wait_timeout = 3600
tmp_table_size = 32M
max_heap_table_size = 32M
slow_query_log = 1
slow_query_log_file = /data/mysql/data/slow.log
log-error = /data/mysql/data/error.log
long_query_time = 2
log-bin = /data/mysql/binlog/mysql-bin
sync_binlog = 0
binlog_cache_size = 4M
max_binlog_cache_size = 500M
max_binlog_size = 500M
expire_logs_days = 7
master_info_repository = TABLE
relay_log_info_repository = TABLE
server-id = 1
gtid_mode = on
enforce_gtid_consistency = 1
log_slave_updates
binlog_format = row
relay_log_recovery = 1
relay-log-purge = 1
key_buffer_size = 16M
read_buffer_size = 2M
read_rnd_buffer_size = 2M
bulk_insert_buffer_size = 64M
#lock_wait_timeout = 3600
innodb_thread_concurrency = 0
innodb_sync_spin_loops = 100
innodb_spin_wait_delay = 30
explicit_defaults_for_timestamp = 1
#thread_handling = pool-of-threads
lower_case_table_names=1
 
transaction_isolation = READ-COMMITTED
innodb_buffer_pool_size = 1000M
innodb_buffer_pool_instances = 1
innodb_data_file_path = ibdata1:1G:autoextend
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 32M
innodb_log_file_size = 1G
innodb_log_files_in_group = 2
innodb_max_undo_log_size = 1G
 
innodb_io_capacity = 400
innodb_io_capacity_max = 800
innodb_flush_neighbors = 0
innodb_write_io_threads = 8
innodb_read_io_threads = 8
innodb_purge_threads = 4
innodb_page_cleaners = 4
innodb_open_files = 65535
innodb_max_dirty_pages_pct = 70
innodb_flush_method = O_DIRECT
innodb_rollback_on_timeout = 1
innodb_file_per_table = 1
default-time-zone='+00:00' 
#performance_schema
performance_schema = 0
 
[mysqldump]
quick
max_allowed_packet = 128M