[client]
port=3306
socket=/tmp/mysql.sock
default-character-set=utf8
[mysql]
no-auto-rehash
default-character-set=utf8
[mysqld]
port=3306
character-set-server=utf8
socket=/tmp/mysql.sock
basedir=/usr/local/mysql
datadir=/mydata/data
#如果你的mysql版本高于5.6.6,关于timestamp为null的时候,可能会报错
explicit_defaults_for_timestamp=true
lower_case_table_names=1
#如果MySql的连接数据达到max_connections时,新来的请求将会被存在堆栈中,以等待某一连接释放资源,该堆栈的数量即back_log,如果等待连接的数量超过back_log,将不被授予连接资源。可以从默认的50升至500
back_log=103
max_connections=10000
max_connect_errors=100000
#缓存
table_open_cache=512
#文档上说,增加table_open_cache,会增加文件描述符,当把table_open_cache设置为很大时,如果系统处理不了那么多文件描述符,那么就会出现客户端失效,连接不上,引用文档上的一句话:
If table_open_cache is set too high, MySQL may run out of file descriptors and refuse connections, fail to perform queries, and be very unreliable.
external-locking=FALSE
sort_buffer_size=2M
join_buffer_size=2M
#发现 thread_cache_size 原来设置好小默认的是0,这个默认值实质上也偏小,建议大的web项目,要调大这个值。
thread_cache_size=51
#MYSQL的查询缓存用于缓存select查询结果,并在下次接收到同样的查询请求时,不再执行实际查询处理而直接返回结果,有这样的查询缓存能提高查询的速度,使查询性能得到优化
query_cache_size=32M
#query_cache_limit=4M
transaction_isolation=REPEATABLE-READ
#tmp_table_size 控制内存临时表的最大值,超过限值后就往硬盘写,写的位置由变量 tmpdir 决定
#max_heap_table_size 用户可以创建的内存表(memory table)的大小.这个值用来计算内存表的最大行数值。
tmp_table_size=96M
max_heap_table_size=96M
sync_binlog = 1 #表示每次事务提交
###***slowqueryparameters
long_query_time=2
slow_query_log = 1
slow_query_log_file=/mydata/data/slow.log
log-bin=mysql-bin
server-id=111
expire_logs_days = 7 #日志过期时间,设置为0则永不过期
binlog_format = ROW #复制模式
max_binlog_size = 1000M #超过max_binlog_size
binlog_cache_size = 16M
#二进制日志缓冲大小,通过show status like ‘binlog_%’;查看调整写入磁盘的次数,写入磁盘为0最好
max_binlog_cache_size = 256M
relay_log_recovery = 1
#当slave从库宕机后,假如relay-log损坏了,
#导致一部分中继日志没有处理,则自动放弃所有未执行的relay-log,
#并且重新从master上获取日志,这样就保证了relay-log的完整性。
gtid_mode = on
enforce_gtid_consistency = 1
#关闭从库同步到主库
log_slave_updates = 0
#relay.info明文存储不安全,把relay.info中的信息记录在table中相对安全。
#可以避免relay.info更新不及时,SLAVE 重启后导致的主从复制出错。
master-info-repository=TABLE
relay-log-info-repository=TABLE
#***MyISAMparameters
key_buffer_size=16M
read_buffer_size=1M
read_rnd_buffer_size=16M
bulk_insert_buffer_size=1M
# innodbstorageengineparameters
innodb_buffer_pool_size=4G #推荐内存的50%-75%
innodb_data_file_path=ibdata1:1G:autoextend
innodb_open_files = 500
innodb_write_io_threads = 16
innodb_read_io_threads = 16
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 4M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
[mysqldump]
quick
max_allowed_packet=32M
[mysqld_safe]
open-files-limit=10240
log-error=/mydata/data/error.log
#pid 亦即 Process ID
pid-file=/mydata/data/mysqld.pid