MySql优化配置
2015-11-03 10:42
507 查看
最近做了个小项目,需要对百万级的数据进行查询检索,我用的数据库是mysql5.6.26,按照网上各种查询的资料对mysql的配置文件进行了优化,记录如下,以备不时之需。
修改文件:my-default.ini,下面是这个文件的全部内容,大部分直接摘自于网络
# 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]
skip-name-resolve
max_connections=512
skip-locking #取消文件系统的外部锁
key_buffer = 512M #索引缓存,根据内存大小而定,如果是独立的db服务器,可以设置高达80%的内存总量
back_log = 200#连接排队列表总数
max_allowed_packet = 2M
#打开表缓存总数,可以避免频繁的打开数据表产生的开销
table_cache = 512
#每个线程排序所需的缓冲
sort_buffer_size = 4M
#MyISAM表发生变化时重新排序所需的缓冲
myisam_sort_buffer_size = 64M
#缓存可重用的线程数
thread_cache = 128
#查询结果缓存
query_cache_size = 128M
#最大并发线程数,cpu数量*2
thread_concurrency = 4
#记录慢查询,然后对慢查询一一优化
log_output=FILE # also can be FILE,TABLE or TABLE or NONE
slow-query-log=1
slow_query_log_file=log-slow-queries.log
long_query_time = 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 = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# 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
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
修改文件:my-default.ini,下面是这个文件的全部内容,大部分直接摘自于网络
# 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]
skip-name-resolve
max_connections=512
skip-locking #取消文件系统的外部锁
key_buffer = 512M #索引缓存,根据内存大小而定,如果是独立的db服务器,可以设置高达80%的内存总量
back_log = 200#连接排队列表总数
max_allowed_packet = 2M
#打开表缓存总数,可以避免频繁的打开数据表产生的开销
table_cache = 512
#每个线程排序所需的缓冲
sort_buffer_size = 4M
#MyISAM表发生变化时重新排序所需的缓冲
myisam_sort_buffer_size = 64M
#缓存可重用的线程数
thread_cache = 128
#查询结果缓存
query_cache_size = 128M
#最大并发线程数,cpu数量*2
thread_concurrency = 4
#记录慢查询,然后对慢查询一一优化
log_output=FILE # also can be FILE,TABLE or TABLE or NONE
slow-query-log=1
slow_query_log_file=log-slow-queries.log
long_query_time = 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 = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# 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
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
相关文章推荐
- MySQL的查询优化
- MySql中分组简介
- mysqli扩展库应用---批量执行sql语句
- mysql 定时任务
- MySql导入导出数据库命令
- mysql扩展中常用函数
- mysql 从库I/O及SQL thread 状态解释
- 为什么要 MySQL 迁移到 Maria DB
- MySQL
- MySQL性能优化的最佳21条经验
- mysql之my.cnf
- 解决Mysql "is marked as crashed and should be repaired"的故障
- 安装mysql 5.7.9绿色版遇到的问题记录
- MySQL存储过程详解 mysql 存储过程
- Mysql命令大全(详细篇)
- 初探mysql
- MySQL 事务的隔离级别与锁
- mysqlbinlog 命令
- mysqldump 常用参数
- mysql show status 详解