ITPub博客

首页 > 数据库 > MySQL > MySQL配置文件优化

MySQL配置文件优化

原创 MySQL 作者:ilydba 时间:2015-07-23 13:59:29 0 删除 编辑
# MySQL一般配置样本
#
# 作者:贾益飞
# 时间:2015年夏
#
# 大家可以用这个生成配置文件后再修改 
# http://tools.percona.com/wizard

# 客户端读取默认配置
[client]
#password = "123456"
port = 3306
socket = /tmp/mysql.sock
default-character-set=utf8

# The MySQL server
[mysqld]
port = 3306
socket = /tmp/mysql.sock

# 数据目录
datadir = /usr/local/mysql/var

# 禁用外部锁定检查,单服务器环境
skip-external-locking

key_buffer_size    = 128M
max_allowed_packet = 8M
table_open_cache   = 1024
net_buffer_length  = 2M
read_buffer_size   = 4M
read_rnd_buffer_size    = 16M
sort_buffer_size        = 32M
myisam_sort_buffer_size = 256M
character-set-server=utf8
# 跳过DNS解析
skip-name-resolve 

# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8
thread_cache_size  = 8
max_connections  = 1024
tmp_table_size   = 256M  
wait_timeout     = 60000 
query_cache_size = 84M
query_cache_type = 1

# Replication Master Server (default)
# 开启2进制日志
log-bin=mysql-bin

# 2进制格式,推荐mixed
binlog_format=mixed
# 日志过期天数
expire_logs_days = 7

# server-id设置值,推荐使用IP末尾数值
server-id = 72

slow-query-log   = 1
long_query_time  = 2 
slow-query-log-file   = /usr/local/mysql/var/slow.log

innodb_data_home_dir  = /usr/local/mysql/var
innodb_data_file_path = ibdata1:20M:autoextend
innodb_log_group_home_dir = /usr/local/mysql/var
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 20M
innodb_additional_mem_pool_size = 4M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
# 设置为0就是等到innodb_log_buffer_size列队满后再统一储存,默认为1
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
# 开启InnoDB单表空间独立
innodb_file_per_table = 1
[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[myisamchk]
key_buffer_size  = 20M
sort_buffer_size = 20M
read_buffer  = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30290247/viewspace-1745604/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2015-06-15

  • 博文量
    15
  • 访问量
    33819