mysql 5.7 的 /etc/my.cnf 参数
下面是 mysql 5.7 的 /etc/my.cnf 的一些常用参数,自己记录一下,随时补充完善。
[client]
port = 3306
default-character-set=utf8mb4
socket=/var/lib/mysql/mysql.sock
[mysql]
port = 3306
default-character-set=utf8mb4
socket=/var/lib/mysql/mysql.sock
[mysqld]
##########################
# summary
##########################
bind-address = 0.0.0.0
port = 3306
basedir=/usr/local/mysql
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
tmpdir = /tmp
pid-file=/tmp/mysqld.pid
#skip-grant-tables
#skip-networking
explicit_defaults_for_timestamp=1
lower_case_table_names=1
table_open_cache = 8000
##########################
# time out
##########################
connect_timeout = 20
wait_timeout = 86400
##########################
# connection
##########################
max_connections = 2000
max_user_connections = 1900
max_connect_errors = 100000
max_allowed_packet = 1G
##########################
# character set
##########################
character-set-server = utf8mb4
collation-server = utf8mb4_bin
##########################
# log bin
##########################
server-id = 1
log_bin = mysql-bin
binlog_format = MIXED
sync_binlog = 1
expire_logs_days =7
binlog_cache_size = 128m
max_binlog_cache_size =512m
max_binlog_size =256M
binlog_ignore_db=mysql
binlog_ignore_db=information_schema
binlog_ignore_db=performation_schema
binlog_ignore_db=sys
##########################
# log relay
##########################
relay_log = mysql-relay-bin
relay_log_purge = on
relay_log_recovery = on
max_relay_log_size = 1G
##########################
# log error
##########################
log_error=/var/log/mysqld_error.log
##########################
# log slow
##########################
slow_query_log = on
slow_query_log_file = /var/log/mysqld_slow.log
long_query_time = 2
log_queries_not_using_indexes = on
##########################
# log general
##########################
general_log = on
general_log_file = /var/log/mysqld_gener.log
##########################
# thread pool
##########################
#thread_handling=pool-of-threads
#thread_handling=one-thread-per-connection
#thread_pool_oversubscribe=8
##########################
# innodb
##########################
innodb_file_per_table=1
innodb_log_file_size=1024M
innodb_log_buffer_size=64M
##########################
# password policy
# after init
##########################
#validate_password_length=4
#validate_password_mixed_case_count=0
#validate_password_number_count=0
#validate_password_policy=0
#validate_password_special_char_count=0