mysql 8.0 my.cnf配置项

本文详细解释了MySQL8.0服务器的配置参数,包括socket路径、日志记录、慢查询、内存缓存、安全选项、连接控制等,并提供了优化建议。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

[client]
socket=/opt/mysqlData/mysql/mysql.sock

[mysqld]

general_log=on
general_log_file=/opt/mysqlData/mysql/centos7-3x86.log
log_timestamps=SYSTEM

slow_query_log=on

init-connect='insert into auditlog.t_audit(id,thread_id,login_time,localname,matchname) values(null,connection_id(),now(),user(),current_user());'


lower-case-table-names=1
#
# 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 = 2048M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_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
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password

datadir=/opt/mysqlData/mysql
socket=/opt/mysqlData/mysql/mysql.sock

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

#audit_json_file=on
#plugin-load=AUDIT=libaudit_plugin.so
#audit_record_cmds = 'insert,delete,update,create,drop,alter,grant,truncate'
#audit_json_log_file=/opt/mysqlData/log/mysql_audit.json
#audit_offset=8600, 8640, 4136, 5616, 496, 0, 0, 32, 64, 160, 584, 8740, 5240, 4248, 4256, 4260, 6896, 1576, 32, 7856, 7896, 7880, 11624, 140, 664, 32

#plugin-load-add=validate_password.so
#服务器在启动时加载插件,并防止在服务器运行时删除插件
#validate-password=FORCE_PLUSE_PERMANENT

connection-control-min-connection-delay=900000
max_connections=1000
max_user_connections=500

wait_timeout=200

bind-address=172.26.77.250


query_cache_size=1024M
query_cache_type=2
max_allowed_packet=256M
 
#在MYSQL暂时停止响应新请求之前
back_log=600
#MySQL允许最大的进程连接数
# max_connections=2000
#指示表调整缓冲区大小
#table_cache=614
#使用–skip-external-locking MySQL选项以避免外部锁定
external-locking=FALSE
#设置在网络传输中一次消息传输量的最大值
max_allowed_packet=8M
# Sort_Buffer_Size 是一个connection级参数
# sort_buffer_size=2M
#用于表间关联缓存的大小
# join_buffer_size=2M
# 服务器线程缓存这个值表示可以重新利用保存在缓存中线程的数量
thread_cache_size=300
# 设置thread_concurrency的值的正确与否, 对mysql的性能影响很大 = thread_concurrency应设为CPU核数的2倍
thread_concurrency=16
#批定用于索引的缓冲区大小,增加它可以得到更好的索引处理性能,对于内存在8GB左右的服务器来说,该参数可设置为512MB。
key_buffer_size=1024M
#批量插入数据缓存大小,可以有效提高插入效率,默认为8M
bulk_insert_buffer_size=64M
# 这对Innodb表来说非常重要
# innodb_buffer_pool_size=2048M
#文件IO的线程数,一般为 4
innodb_file_io_threads=8

mysql 社区版下载

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值