Home  >  Article  >  Database  >  mysql优化配置参数_MySQL

mysql优化配置参数_MySQL

WBOY
WBOYOriginal
2016-05-27 14:08:241055browse

bitsCN.com 第一种

#This File was made using the WinMySQLAdmin 1.4 Tool
#2004-2-23 16:28:14
#Uncomment or Add only the keys that you know how works.
#Read the MySQL Manual for instructions
[mysqld]
basedir=D:/mysql
#bind-address=210.5.*.*
datadir=D:/mysql/data
#language=D:/mysql/share/your language directory
#slow query log#=
#tmpdir#=
#port=3306
set-variable = max_connections=1500
skip-locking
#skip-networking
set-variable = key_buffer=384M
set-variable = max_allowed_packet=1M
set-variable = table_cache=512
set-variable = sort_buffer=2M
set-variable = record_buffer=2M
set-variable = thread_cache=8
# Try number of CPU's*2 for thread_concurrency
set-variable = thread_concurrency=8
set-variable = myisam_sort_buffer_size=64M
#set-variable = connect_timeout=5
#set-variable = wait_timeout=5
server-id = 1
[isamchk]
set-variable = key_buffer=128M
set-variable = sort_buffer=128M
set-variable = read_buffer=2M
set-variable = write_buffer=2M
[myisamchk]
set-variable = key_buffer=128M
set-variable = sort_buffer=128M
set-variable = read_buffer=2M
set-variable = write_buffer=2M
[WinMySQLadmin]
Server=D:/mysql/bin/mysqld-nt.exe

这个方案,整体够用了,但是在pconnect和最大连接数上,需要研究max_connections没必要那么大,我个人认为几百就够,否则给服务器加大了不少负担,经常会当机连接超时的设置也要根据实际情况调整,大家可以自由调整,然后观察效果如何。
第二种
  7、MYSQL 的优化(/etc/my.cnf)
1)确认在“[mysqld]”部分加入了“skip-innodb”和“skip-bdb”参数;
2)确认在“[mysqld]”部分加入了“skip-name-resolve”和“skip-locking”参数;
3)如果不需要的话,可以将二进制日志(binlog)停掉,方法是将“log-bin”注释掉;
4)在内存允许的情况下,对一些参数进行重新配置,目标在于将大部分操作集中于内存中,尽量不进行磁盘操作,对于我的 MYSQL 服务器我是如下修改的,基于 2G 内存情况:

[mysqld]
set-variable = key_buffer=512M
set-variable = max_allowed_packet=4M
set-variable = table_cache=1024
set-variable = thread_cache=64
set-variable = join_buffer_size=32M
set-variable = sort_buffer=32M
set-variable = record_buffer=32M
set-variable = max_connections=512
set-variable = wait_timeout=120
set-variable = interactive_timeout=120
set-variable = max_connect_errors=30000
set-variable = long_query_time=1
set-variable = max_heap_table_size=256M
set-variable = tmp_table_size=128M
set-variable = thread_concurrency=8
set-variable = myisam_sort_buffer_size=128M

你可以根据“show status”命令返回的状态进行微调。我主要注意以下变量的数值,越小越好,最好为零:)
Created_tmp_disk_tables
Created_tmp_tables
Created_tmp_files
Slow_queries
另外 mysql wait_timeout 那个值设置大了没用 做10左右就可了 (大C说得)
wait_timeout是使用长久连线时 空闲进程的控制只要数据库在连接状态 他是不进行干预的 不管是否有查询或更新操作把这个设置小一点 再使用pconnect就比较理想了 ;)
timeout的

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn