# For advice on how to change settings please see# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html[mysqld]datadir = /var/lib/mysqlsocket = /var/lib/mysql/mysql.socklog-error = /var/log/mysqld.logpid-file = /var/run/mysqld/mysqld.pidcharacter-set-server = utf8mb4symbolic-links = 0# 开启binlogserver-id = 1log_bin = /var/lib/mysql/mysql-binlog_bin_index = /var/lib/mysql/mysql-bin.indexmax_binlog_size = 512M# 多少次事务提交后,将binlog刷新到磁盘 默认为0,表示由系统控制sync_binlog = 0# 当本机作为slave时,是否将master的binlog记录到本地binlog(便于多级主从)log_slave_updates = on# master 复制信息存储方式 file/tablemaster-info-repository = file# relay log 策略 保证主从一致性relay_log_recovery = on# slave 进程随mysql服务启动而启动skip-slave-start = on# 允许sql导入本地文件local_infile = on# 数据库内部 资源/等待监控performance_schema = off# 开启慢日志long_query_time = 2slow-query-log = on slow-query-log-file = /var/lib/mysql/slow-query.log# 慢日志存储方式 file/tablelog_output = file# 记录 未使用index且速度慢的查询log-queries-not-using-indexes = on# 设置事务模式 不产生GTID事务,为slave时,接收GTID事务和匿名事务gtid-mode = OFF_PERMISSIVE# 设置最大连接数 DBInstanceMemory/12Mmax_connections = 1000# 终止空闲时间超过60秒 的连接wait_timeout = 60# 单个主机错误连接操作 100次 锁定主机max_connect_errors = 100# 密码过期策略 永不过期default_password_lifetime = 0# 默认存储引擎default_storage_engine = InnoDB# timestamp时间格式策略 字段可以为null时,插入null会记录null,而不是当前时间explicit_defaults_for_timestamp = 1# 此值为 max_connections*每次查询的表数量 不宜过大table_open_cache = 2046table_open_cache_instances = 16# 线程创建时候分配的内存大小 SQL越复杂/存储过程递归越多 此值响应增加thread_stack = 256K# innodb缓冲池大小 innodb_buffer_pool_size = DBInstanceMemory * 3/4innodb_buffer_pool_size = 1G# 此值需要通过业务需求调整# 内存和表越多分配值越大 https://dev.mysql.com/doc/refman/5.7/en/server-configuration.htmlread_buffer_size = 1M# 开启独立表空间innodb_file_per_table = 1# innodb 数据刷新到磁盘方式innodb_flush_method = O_DIRECT# 事务在内存中缓冲大小(2-8M)innodb_log_buffer_size = 8M# 单个日志文件大小innodb_log_file_size = 256M# 事务提交后的回收udo页的线程innodb_purge_threads = 1[client]default-character-set = utf8mb4[mysql]default-character-set = utf8mb4