lihongjie0209 / myblog

4 stars 0 forks source link

MySQL: 配置参考 #277

Open lihongjie0209 opened 3 years ago

lihongjie0209 commented 3 years ago

开启二进制日志

server_id=1
log_bin=mysql.bin
log_slave_updates=1 # 主从复制的时候也记录bin log
sync_bin_log=1
lihongjie0209 commented 3 years ago

开启慢查询日志


log_queries_not_using_indexes   = 1
long_query_time                 = 5
slow_query_log                  = 0     # Disabled for production
slow_query_log_file             = /var/lib/mysql/mysql_slow.log
log_slow_admin_statements=ON
lihongjie0209 commented 3 years ago

开启错误日志

log_error                       = /var/lib/mysql/mysql_error.log
lihongjie0209 commented 3 years ago

基本配置

server_id=1
datadir=/opt/data
port=3306
skip-name-resolve
skip-ssl
max_connections=4500
max_user_connections=4000
max_connect_errors=65536
max_allowed_packet=128M
connect_timeout=8
net_read_timeout=30
net_write_timeout=60
back_log=1024
lihongjie0209 commented 3 years ago

开启gtid

    enforce_gtid_consistency=ON
    gtid_mode=ON
lihongjie0209 commented 3 years ago

默认编码为 utf8mb4

collation-server = utf8mb4_unicode_520_ci
init-connect='SET NAMES utf8mb4'
character-set-server = utf8mb4