首页 > 数据库技术 > 详细

MySQL Config

时间:2020-07-13 16:19:26      阅读:66      评论:0      收藏:0      [点我收藏+]

开启查询日志 

在 my.ini 配置文件的 [mysqld] 下增加:

slow_query_log=TRUE
slow_query_log_file=/tmp/slow_query_log.txt
long_query_time=3

重启 mysql 服务,查询是否生效

show variables like ‘%quer%‘;

 

主从

# 保证主从一致性,建议两个都设置为 1
sync_binlog
innodb_fush_log_at_trx_commit

 

缓存

# 建议 4M 或 8M,可以应付 sort/join/read
sort/join/read/read rnd buffer

# 建议 16M 或 32M,经常产生临时表可以加大一点 128M
tmp/heap table

# 1G-2G
innodb_buffer_pool_size

 

其它配置

# 0.01(10毫秒)-0.1(100毫秒) 范围,记录超过时间的 SQL。设置 0,记录所有的 SQL
long_query_time

# 记录没有使用索引的 SQL,on/60,每分钟记录多少条
log_queries_not_using_indexes
log_throttle_queries_not_using_indexes

# 交互模式的超时时间,建议 300-600 秒
interactive_timeout
wait_timeout

# 表锁的超时时间,默认一年,建议 30-60 分钟
lock_wait_timeout

# 设定时区
time_zone

# 是否开启线程池
thread_handling

# 默认 75%,建议 50% innodb_max_dirty_pages_pct # 默认 0,不用改动 innodb_thread_concurrency # 行锁等待时间,默认 50 秒,建议设置 5-20 秒 innodb_lock_wait_timeout # 默认 0,不用改动 innodb_max_purge_lag # 建议 2G/3 组 innodb_log_file_size innodb_log_files_in_group # innodb 最大 io innodb_io_capacity innodb_io_capacity_max

 


https://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

https://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html

中文 5.1:https://dev.mysql.com/doc/index-archive.html

中文 5.1 在线:https://jhxxb.gitee.io/blog/refman-5.1-zh.html-chapter/index.html

http://ourmysql.com/

MySQL Config

原文:https://www.cnblogs.com/jhxxb/p/13291593.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!