mysql的配置文件

前言

以下是经过实践的mysql配置文件,版本信息:5.6.41-log

内容

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
# charset
# init_connect = 'SET NAMES utf8'
character_set_server = utf8 #服务端字符集
collation_server = utf8_general_ci #服务端排序规则
lower_case_table_names = 1 #表名大小写:0--区分,1--不区分
# connection
max_connections = 1000 #设置最大连接,允许最大连接为16384
back_log = 2000 #MySQL的连接达到max_connections时,新的请求被存到堆栈的数量上限
max_allowed_packet = 1024M #单条sql允许的数据量
# transaction
default-storage-engine = InnoDB #默认存储引擎 
transaction-isolation = READ-COMMITTED #默认事务隔离级别
# innodb
innodb_open_files = 3000 #单库允许打开的表数量
innodb_read_io_threads = 32 #读线程数
innodb_write_io_threads = 16 #写线程数
innodb_log_file_size = 512M #控制事务日志ib_logfile的大小,修改后需要干净关闭MySQL,删除原ib_logfile,重启MySQL重新生成ib_logifle
innodb_buffer_pool_size = 512M #innodb表的索引,数据,插入数据时的缓冲
# bin-log slave节点不需要开启binlog,只用接受master的binlog就可以。master的binlog一定要配置server_id
server_id = 222 # 编号集群唯一就可以,推荐服务ip结尾,版本5.7以上必须指定
expire_logs_days = 7 # binlog和relaylog日志保存期限
# relay-log master节点不需要开启中继日志,slave节点需要开启来接受master的binlog,后续slave节点用sql线程读取中继日志然后同步到数据库
relay_log = /var/lib/mysql/relay-bin # 开启中继日志,等同于同时配置relay_log=on, relay_log_basename和relay_log_index
relay_log_recovery = ON # 当slave从库宕机后,假如relay-log损坏了,导致一部分中继日志没有处理,则自动放弃所有未执行的relay-log,并且重新从master上获取日志
master-info-repository = TABLE
relay-log-info-repository = TABLE
# 主从同步从库专用设置
read_only = ON # 数据库只读
# log_slave_updates = 1 # 从库binlog才会记录主库同步的操作日志,配合从库的bin-log实现级联同步
# slow-log
slow_query_log = ON # 慢查询日志
slow_query_log_file=/var/lib/mysql/slow.log # 慢查询日志名和位置
long_query_time=2 # SQL语句运行时间阈值,执行时间大于参数值的语句才会被记录下来
#sql_mode = ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
sql_mode = STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION
[client]
default-character-set = utf8 
[mysql]
default-character-set = utf8 

你可能感兴趣的:(mysql,mysql,配置文件)