5.18日音訊,my.ini知識及詳解。CLIENTSECTION
客戶端章節(jié):
[client]
port=3306端口號=3306
[mysql]
default-character-set=latin1默認字符編碼=latin1
SERVERSECTION
服務(wù)端章節(jié)
[mysqld]
#TheTCP/IPPorttheMySQLServerwilllistenon
TCP/IPPort監(jiān)聽mysql的端口號
port=3306
#Pathtoinstallationdirectory.Allpathsareusuallyresolvedrelativetothis.
安裝目錄路徑。所有的路徑都是作為這個路徑的相對路徑。
basedir="E:/programfile/MySql5.1/"
#Pathtothedatabaseroot
數(shù)據(jù)庫數(shù)據(jù)的根路徑
datadir="C:/ProgramData/MySQL/MySQLServer5.1/Data/"
#Thedefaultcharactersetthatwillbeusedwhenanewschemaortableis
#createdandnocharactersetisdefined
默認的字符集編碼作用于當一個新的schema或者表被創(chuàng)建的時候沒有指定字符集。
default-character-set=latin1
#Thedefaultstorageenginethatwillbeusedwhencreatenewtableswhen
默認的存儲引擎作用于當創(chuàng)建新表的時候
default-storage-engine=INNODB
#SettheSQLmodetostrict
設(shè)置嚴格的SQL模型
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
#ThemaximumamountofconcurrentsessionstheMySQLserverwill
#allow.Oneoftheseconnectionswillbereservedforauserwith
#SUPERprivilegestoallowtheadministratortologinevenifthe
#connectionlimithasbeenreached.
Mysql服務(wù)端允許最大的并發(fā)數(shù),其中一個連接將留給用戶使用超級權(quán)限連接數(shù)據(jù)庫,即使連接數(shù)已經(jīng)達到最高限額
max_connections=100
#QuerycacheisusedtocacheSELECTresultsandlaterreturnthem
#withoutactualexecutingthesamequeryonceagain.Havingthequery
#cacheenabledmayresultinsignificantspeedimprovements,ifyour
#havealotofidenticalqueriesandrarelychangingtables.Seethe
#"Qcache_lowmem_prunes"statusvariabletocheckifthecurrentvalue
#ishighenoughforyourload.
#Note:Incaseyourtableschangeveryoftenorifyourqueriesare
#textuallydifferenteverytime,thequerycachemayresultina
#slowdowninsteadofaperformanceimprovement.
查詢緩存用于在緩存中SELECT結(jié)果,返回不是實際查詢數(shù)據(jù)庫的結(jié)果。
從緩存中查詢的結(jié)果會顯著的提升查詢速度,如果你有很多相同的查詢和很少改變表結(jié)構(gòu)。
查看“Qcache_lowmem_prunes”狀態(tài)變量來檢查當前值對于你的負載是否足夠高。
NOTE:如果你的表結(jié)構(gòu)經(jīng)常改變或者,你每次查詢都不相同,那么使用查詢緩存結(jié)果可能不是一個性能改進。
query_cache_size=15M
#Thenumberofopentablesforallthreads.Increasingthisvalue
#increasesthenumberoffiledescriptorsthatmysqldrequires.
#Thereforeyouhavetomakesuretosettheamountofopenfiles
#allowedtoatleast4096inthevariable"open-files-limit"in
#section[mysqld_safe]
所有的線程打開表的數(shù)量。
table_cache=256
#Maximumsizeforinternal(in-memory)temporarytables.Ifatable
#growslargerthanthisvalue,itisautomaticallyconvertedtodisk
#basedtableThislimitationisforasingletable.Therecanbemany
#ofthem.
臨時表最大內(nèi)存大小。如果一個表生長大于這個值,它會自動轉(zhuǎn)換為磁盤,這只是限制單個表,可以有很多個
tmp_table_size=18M
#Howmanythreadsweshouldkeepinacacheforreuse.Whenaclient
#disconnects,theclient'sthreadsareputinthecacheiftherearen't
#morethanthread_cache_sizethreadsfrombefore.Thisgreatlyreduces
#theamountofthreadcreationsneededifyouhavealotofnew
#connections.(Normallythisdoesn'tgiveanotableperformance
#improvementifyouhaveagoodthreadimplementation.)
有很多線程我們應(yīng)該保持在一個緩存里以便重用。在沒有超過超過線程緩存大小之前,當一個客戶端斷開連接時,把客戶端線程放在緩存中。如果你有很多新的連接,那么這大大降低了線程的數(shù)量創(chuàng)造需要。(如果你有一個好的改進線程實現(xiàn)方案,那么這個并不會給出一個顯著的性能)
thread_cache_size=8
#***MyISAMSpecificoptions
MYISAM特殊配置項
#ThemaximumsizeofthetemporaryfileMySQLisallowedtousewhile
#recreatingtheindex(duringREPAIR,ALTERTABLEorLOADDATAINFILE.
#Ifthefile-sizewouldbebiggerthanthis,theindexwillbecreated
#throughthekeycache(whichisslower).
Mysql臨時文件允許使用重建索引(在修復(fù),修改表結(jié)構(gòu),導(dǎo)入數(shù)據(jù)文件時)的最大大小。
如果文件大小會比這個大,該指數(shù)將被創(chuàng)建通過鍵緩存(很慢)
myisam_max_sort_file_size=100G
#Ifthetemporaryfileusedforfastindexcreationwouldbebigger
#thanusingthekeycachebytheamountspecifiedhere,thenpreferthe
#keycachemethod.Thisismainlyusedtoforcelongcharacterkeysin
#largetablestousetheslowerkeycachemethodtocreatetheindex.
如果臨時文件用于快速創(chuàng)建索引將比使用鍵緩存更大,那么鍵緩存的方法是很好的。這主要用于在比較大型的表使用緩慢的基礎(chǔ)上,使用長字符串創(chuàng)建索引。
myisam_sort_buffer_size=35M
#SizeoftheKeyBuffer,usedtocacheindexblocksforMyISAMtables.
#Donotsetitlargerthan30%ofyouravailablememory,assomememory
#isalsorequiredbytheOStocacherows.Evenifyou'renotusing
#MyISAMtables,youshouldstillsetitto8-64Masitwillalsobe
#usedforinternaltemporarydisktables.
在MyISAM表里用于緩存索引塊。不要把它設(shè)置為大于你的可用內(nèi)存的30%,因為一些內(nèi)存還需要由OS緩存行,即使您沒有使用MyISAM表,您仍然應(yīng)該將其設(shè)置為8-64m,因為它也會用于內(nèi)部臨時磁盤表
key_buffer_size=8M
#SizeofthebufferusedfordoingfulltablescansofMyISAMtables.
#Allocatedperthread,ifafullscanisneeded.
MyISAM表用來做全表掃描的緩沖區(qū)大小
如果需要一個完整的掃描,就分配給每一個線程
read_buffer_size=64K
read_rnd_buffer_size=256K
#ThisbufferisallocatedwhenMySQLneedstorebuildtheindexin
#REPAIR,OPTIMZE,ALTERtablestatementsaswellasinLOADDATAINFILE
#intoanemptytable.Itisallocatedperthreadsobecarefulwith
#largesettings.
這個緩沖區(qū)是分配給:當MYSQL在需要修理,OPTIMZE,修改表結(jié)構(gòu)語句以及導(dǎo)入加載數(shù)據(jù)
到一個空表時重建索引。它是分配給每個線程,所以在大型設(shè)置中要小心使用。
sort_buffer_size=256K
#***INNODBSpecificoptions***
INNODB特殊項
INNODB保存數(shù)據(jù)目錄
innodb_data_home_dir="E:/MySQLDatafiles/"
#UsethisoptionifyouhaveaMySQLserverwithInnoDBsupportenabled
#butyoudonotplantouseit.Thiswillsavememoryanddiskspace
#andspeedupsomethings.
#skip-innodb
#AdditionalmemorypoolthatisusedbyInnoDBtostoremetadata
#information.IfInnoDBrequiresmorememoryforthispurposeitwill
#starttoallocateitfromtheOS.Asthisisfastenoughonmost
#recentoperatingsystems,younormallydonotneedtochangethis
#value.SHOWINNODBSTATUSwilldisplaythecurrentamountused.
InnoDB存儲元數(shù)據(jù)信息時的額外的內(nèi)存池。如果需要更多的內(nèi)存,InnoDB為此它會分配它的操作系統(tǒng)內(nèi)存。因為在大多數(shù)操作系統(tǒng)中,這已經(jīng)是足夠快的了,所以通常不需要修改這個值。SHOWINNODBSTATUS會顯示當前的使用量
innodb_additional_mem_pool_size=2M
#Ifsetto1,InnoDBwillflush(fsync)thetransactionlogstothe
#diskateachcommit,whichoffersfullACIDbehavior.Ifyouare
#willingtocompromisethissafety,andyouarerunningsmall
#transactions,youmaysetthisto0or2toreducediskI/Otothe
#logs.Value0meansthatthelogisonlywrittentothelogfileand
#thelogfileflushedtodiskapproximatelyoncepersecond.Value2
#meansthelogiswrittentothelogfileateachcommit,butthelog
#fileisonlyflushedtodiskapproximatelyoncepersecond.
如果設(shè)置為1,InnoDB會在每個提交磁盤沖洗事務(wù)日志,這提供了完整的ACID的行為.
如果你想安全,并且正在執(zhí)行一些小操作,你可以設(shè)置為0或者2在減少磁盤I/O日志。
#innodb_flush_log_at_trx_commit=1
#ThesizeofthebufferInnoDBusesforbufferinglogdata.Assoonas
#itisfull,InnoDBwillhavetoflushittodisk.Asitisflushed
#oncepersecondanyway,itdoesnotmakesensetohaveitverylarge
#(evenwithlongtransactions).
這個大小用于緩沖InnoDB在緩沖日志數(shù)據(jù)。一旦它滿了,InnoDB會在磁盤上釋放它。
它無論如何都會一秒緩沖一次,這對于非常大的日志是沒有意義的。(即使有長事務(wù))
innodb_log_buffer_size=1M
#InnoDB,unlikeMyISAM,usesabufferpooltocachebothindexesand
#rowdata.ThebiggeryousetthisthelessdiskI/Oisneededto
#accessdataintables.Onadedicateddatabaseserveryoumaysetthis
#parameterupto80%ofthemachinephysicalmemorysize.Donotsetit
#toolarge,though,becausecompetitionofthephysicalmemorymay
#causepagingintheoperatingsystem.Notethaton32bitsystemsyou
#mightbelimitedto2-3.5Gofuserlevelmemoryperprocess,sodonot
#setittoohigh.
InnoDB,不像MyISAM,使用一個緩沖池來緩存的兩個索引和行數(shù)據(jù)。這個磁盤I/O設(shè)置的更大,需要訪問的數(shù)據(jù)表更少。在專用的數(shù)據(jù)庫服務(wù)器上你可以設(shè)置參數(shù)高達80%的機器的物理內(nèi)存大小。不用把它設(shè)置的太大,不過,因為在操作系統(tǒng)中競爭的物理內(nèi)存可能導(dǎo)致內(nèi)存不夠分。注意,32位系統(tǒng)上的你可能被限制在2-3.5g的用戶級內(nèi)存,所以不要設(shè)置的太高。
innodb_buffer_pool_size=83M
#Sizeofeachlogfileinaloggroup.Youshouldsetthecombinedsize
#oflogfilestoabout25%-100%ofyourbufferpoolsizetoavoid
#unneededbufferpoolflushactivityonlogfileoverwrite.However,
#notethatalargerlogfilesizewillincreasethetimeneededforthe
#recoveryprocess.
每個日志文件在日志組里的大小。你應(yīng)該將日志文件大約為25%--100%緩沖池大小合并來避免不必要的緩沖池的緩沖行為覆蓋日志文件。然而,一個大的日志文件將增加復(fù)蘇過程的所需時間。
innodb_log_file_size=17M
#NumberofthreadsallowedinsidetheInnoDBkernel.Theoptimalvalue
#dependshighlyontheapplication,hardwareaswellastheOS
#schedulerproperties.Atoohighvaluemayleadtothreadthrashing.
InnoDB的內(nèi)核允許多線程。最高性能取決于高的應(yīng)用程序、硬件以及操作系統(tǒng)。
一個很高的值可能導(dǎo)致線程抖動
innodb_thread_concurrency=8