日期:2014-05-16  浏览次数:20771 次

MySQL典型配置
# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock

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

# 避免MySQL的外部锁定,减少出错几率增强稳定性
skip-locking

bind-address = 172.30.6.2
datadir = /data/dbdata

# 每个表使用不同的数据文件
innodb_file_per_table

# 同步时跳过mysql数据库
replicate-ignore-db = mysql

# 缺省使用innodb表类型
default-table-type = innodb

# 缺省使用gbk字符集
default-character-set=gbk

#最大连接数限制为100个
max_connections = 100

# 每个连接独立使用的内存为 sort_buffer_size+read_buffer_size+join_buffer_size
sort_buffer_size = 4M
read_buffer_size = 2M

# 关闭自动提交选项
init_connect='set autocommit=0'

# 开启慢查询日志, 仅对select操作有效, 包括不使用索引的查询.
log_slow_queries

# 超过此时间的查询被视为慢查询, 单位 秒.
long_query_time = 3

# 最大包的大小
max_allowed_packet = 16M

# key_buffer_size 仅对myisam表有效. 但由于mysql的临时表/系统表都是myisam,因此需要设置.
key_buffer_size = 32M

table_cache = 512

read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M

# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8

# InnoDB的配置
innodb_data_home_dir = /data/dbdata/innodb
innodb_data_file_path = ibdata1:1000M;ibdata2:100M:autoextend
innodb_log_group_home_dir = /data/dbdata/innodb
innodb_log_arch_dir = /data/dbdata/innodb

innodb_buffer_pool_size = 1G
innodb_additional_mem_pool_size = 20M

# innodb_log_file_size 设置成innodb_buffer_pool_size的25%
innodb_log_file_size = 250M

# InnoDB用来往磁盘上的日志文件写操作的缓冲区的大小。明智的值是从1MB到8MB。
innodb_log_buffer_size = 8M

# 关闭实时刷新事务日志的功能,非常影响insert的性能. 关闭后,mysql仍然会每秒钟刷新一次.
innodb_flush_log_at_trx_commit = 0
innodb_lock_wait_timeout = 50

# 关闭XA事务
innodb_support_xa = 0

[mysqldump]
quick
max_allowed_packet = 16M

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

[isamchk]
key_buffer = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M

[myisamchk]
key_buffer = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout