[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
wait_timeout = 28800
interactive_timeout = 28800
[mysqld]
#authentication_policy = mysql_native_password,caching_sha2_password
# 基础
binlog_cache_size = 384K
thread_stack = 512K
# 将过大的 per-connection buffers 调小,避免并发时内存被瞬间耗尽
join_buffer_size = 512K
max_heap_table_size = 256M
wait_timeout = 28800
interactive_timeout = 28800
net_read_timeout = 120
net_write_timeout = 120
port = 3306
socket = /tmp/mysql.sock
datadir = /www/server/data
default_storage_engine = InnoDB
# 保留但合理化的缓存/元数据配置
performance_schema_max_table_instances = 400
table_definition_cache = 400
# skip-external-locking 已不推荐,保留但注释(如需可去掉注释)
# skip-external-locking
# MyISAM 缓存(若主要用 InnoDB,给小一点)
key_buffer_size = 64M
# 合理化 max_allowed_packet(100G 无效且危险)
max_allowed_packet = 256M
table_open_cache = 5200
# 每连接排序/读缓冲合理化
sort_buffer_size = 1024K
net_buffer_length = 4K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 128M
# 线程缓存 - 减少默认过大值
thread_cache_size = 128
# 临时表大小调整为合理值,避免磁盘/内存暴涨
tmp_table_size = 256M
# 保持 max_heap_table_size 与 tmp_table_size 一致
max_heap_table_size = 128M
default_authentication_plugin = mysql_native_password
lower_case_table_names = 1
sql-mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
# 移除 max_execution_time(你要求删除)
# max_execution_time = 60000 <-- removed per request
explicit_defaults_for_timestamp = true
#开启 skip-name-resolve 就是告诉 MySQL 不要做 DNS 解析 只用 IP 来比对 Host
skip-name-resolve
# 连接和并发
max_connections = 300
max_connect_errors = 1000
open_files_limit = 65535
# binlog / replication
log-bin = mysql-bin
# 原来是 mixed,改为 ROW 更可靠;若坚持 mixed 可改回
binlog_format = MIXED
server-id = 1
# 600000 秒约 6.94 天,保留原意(也可改为 604800 = 7天)
binlog_expire_logs_seconds = 600000
slow_query_log = 1
slow-query-log-file = /www/server/data/mysql-slow.log
long_query_time = 0.1
# 排查阶段可开,平时若日志量大可考虑关闭
log_queries_not_using_indexes = ON
early-plugin-load = ""
# 你指出的三个 InnoDB 路径(已加入)
innodb_data_home_dir = /www/server/data
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /www/server/data
# InnoDB 相关(保留你原意,但稍作稳妥调整)
# 你原写 9182M,我保留 9182M(接近 9G),适合在 19GB 的机器上并为 Redis/PHP 预留空间
innodb_buffer_pool_size = 6144M
innodb_log_file_size = 1024M
innodb_log_buffer_size = 256M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
# 较高 dirty 比例会导致突发 checkpoint,建议 75,但保留你原意 90 可改
innodb_max_dirty_pages_pct = 75
# 在 MySQL 8 中一般不必手动微调 IO 线程,删除以使用内核自动调整
#innodb_read_io_threads = 10
#innodb_write_io_threads = 10
innodb_buffer_pool_instances = 8
innodb_redo_log_capacity=2G
[mysqldump]
quick
max_allowed_packet = 256M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 64M
sort_buffer_size = 8M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
这是一百万笔资料量再做查询时,同时又有不同网站调用同一个数据库,大概优化的方向,但是不一定完全准确,目前已经测试半年

剧搜博客