anxin-ruoyi/docker/configs/my.cnf.dev
2026-01-08 20:47:24 +08:00

75 lines
1.9 KiB
Plaintext

# MySQL配置文件 - 开发环境
# 针对开发环境优化的MySQL配置
[mysqld]
# 基础配置
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
# 字符集配置
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect = 'SET NAMES utf8mb4'
# 网络配置
bind-address = 0.0.0.0
max_connections = 100
max_connect_errors = 10000
max_allowed_packet = 32M
interactive_timeout = 300
wait_timeout = 300
# 缓存配置 - 开发环境轻量化
key_buffer_size = 64M
max_allowed_packet = 32M
table_open_cache = 1000
sort_buffer_size = 2M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 20
# query_cache已在MySQL 8.0中移除
# query_cache_type = 1
# query_cache_size = 64M
# query_cache_limit = 1M
# InnoDB配置 - 开发环境轻量化
innodb_buffer_pool_size = 256M
innodb_log_file_size = 64M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 2 # 开发环境可以牺牲一些安全性换取性能
innodb_lock_wait_timeout = 50
innodb_file_per_table = 1
# 日志配置 - 开发环境详细日志
log_error = /var/log/mysql/error.log
slow_query_log = 1
slow_query_log_file = /var/log/mysql/slow.log
long_query_time = 1 # 开发环境更严格的慢查询阈值
log_queries_not_using_indexes = 1
# 二进制日志配置 - 开发环境可选
# log_bin = /var/log/mysql/mysql-bin.log
# binlog_format = ROW
# binlog_expire_logs_seconds = 86400 # 1天
# max_binlog_size = 50M
# 安全配置 - MySQL 8.0兼容
sql_mode = STRICT_TRANS_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
# 开发环境特殊配置
general_log = 1 # 开发环境启用通用日志
general_log_file = /var/log/mysql/general.log
[mysql]
default-character-set = utf8mb4
[client]
default-character-set = utf8mb4