Mysql My.ini詳細說明 CLIENT SECTION 客戶端章節: [client] port=3306 端口號=3306 [mysql] default-character-set=latin1 默認字符編碼=latin1 SERVER SECTION 服務端章節 [mysqld] # The TCP/IP Port the MySQL Server will listen on TCP/IP Port 監聽mysql的端口號 port=3306 #Path to installation directory. All paths are usually resolved relative to this. 安裝目錄路徑 。所有的路徑都是作為這個路徑的相對路徑。 basedir="E:/programfile/MySql5.1/" #Path to the database root 數據庫數據的根路徑 datadir="C:/ProgramData/MySQL/MySQL Server 5.1/Data/" # The default character set that will be used when a new schema or table is # created and no character set is defined 默認的字符集編碼作用於當一個新的schema 或者表被創建的時候沒有指定字符集。 default-character-set=latin1 # The default storage engine that will be used when create new tables when 默認的存儲引擎作用於當創建新表的時候 default-storage-engine=INNODB # Set the SQL mode to strict 設置嚴格的SQL模型 sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" # The maximum amount of concurrent sessions the MySQL server will # allow. One of these connections will be reserved for a user with # SUPER privileges to allow the administrator to login even if the # connection limit has been reached. Mysql 服務端允許最大的並發數,其中一個連接將留給用戶使用超級權限連接數據庫,即使連接數已經達到最高限額 max_connections=100 # Query cache is used to cache SELECT results and later return them # without actual executing the same query once again. Having the query # cache enabled may result in significant speed improvements, if your # have a lot of identical queries and rarely changing tables. See the # "Qcache_lowmem_prunes" status variable to check if the current value # is high enough for your load. # Note: In case your tables change very often or if your queries are # textually different every time, the query cache may result in a # slowdown instead of a performance improvement. 查詢緩存用於在緩存中SELECT結果,返回不是實際查詢數據庫的結果。 從緩存中查詢的結果會顯著的提升查詢速度,如果你有很多相同的查詢和很少改變表結構。 查看“Qcache_lowmem_prunes”狀態變量來檢查當前值對於你的負載是否足夠高。 NOTE:如果你的表結構經常改變或者,你每次查詢都不相同,那麼使用查詢緩存結果可能不是一個性能改進。 query_cache_size=15M # The number of open tables for all threads. Increasing this value # increases the number of file descriptors that mysqld requires. # Therefore you have to make sure to set the amount of open files # allowed to at least 4096 in the variable "open-files-limit" in # section [mysqld_safe] 所有的線程打開表的數量。 table_cache=256 # Maximum size for internal (in-memory) temporary tables. If a table # grows larger than this value, it is automatically converted to disk # based table This limitation is for a single table. There can be many # of them. 臨時表最大內存大小。如果一個表生長大於這個值,它會自動轉換為磁盤,這只是限制單個表,可以有很多個 tmp_table_size=18M # How many threads we should keep in a cache for reuse. When a client # disconnects, the client's threads are put in the cache if there aren't # more than thread_cache_size threads from before. This greatly reduces # the amount of thread creations needed if you have a lot of new # connections. (Normally this doesn't give a notable performance # improvement if you have a good thread implementation.) 有很多線程我們應該保持在一個緩存裡以便重用。在沒有超過超過線程緩存大小之前,當一個客戶端斷開連接時,把客戶端線程放在緩存中。如果你有很多新的連接,那麼這大大降低了線程的數量創造需要。(如果你有一個好的改進線程實現方案,那麼這個並不會給出一個顯著的性能) thread_cache_size=8 #*** MyISAM Specific options MYISAM 特殊配置項 # The maximum size of the temporary file MySQL is allowed to use while # recreating the index (during REPAIR, ALTER TABLE or LOAD DATA INFILE. # If the file-size would be bigger than this, the index will be created # through the key cache (which is slower). Mysql臨時文件允許使用重建索引(在修復,修改表結構,導入數據文件時)的最大大小。 如果文件大小會比這個大,該指數將被創建通過鍵緩存(很慢) myisam_max_sort_file_size=100G # If the temporary file used for fast index creation would be bigger # than using the key cache by the amount specified here, then prefer the # key cache method. This is mainly used to force long character keys in # large tables to use the slower key cache method to create the index. 如果臨時文件用於快速創建索引將比使用鍵緩存更大,那麼鍵緩存的方法是很好的。這主要用於在比較大型的表使用緩慢的基礎上,使用長字符串創建索引。 myisam_sort_buffer_size=35M # Size of the Key Buffer, used to cache index blocks for MyISAM tables. # Do not set it larger than 30% of your available memory, as some memory # is also required by the OS to cache rows. Even if you're not using # MyISAM tables, you should still set it to 8-64M as it will also be # used for internal temporary disk tables. 在MyISAM表裡用於緩存索引塊。不要把它設置為大於你的可用內存的30%,因為一些內存還需要由OS緩存行,即使您沒有使用MyISAM表,您仍然應該將其設置為8 - 64 m,因為它也會用於內部臨時磁盤表 key_buffer_size=8M # Size of the buffer used for doing full table scans of MyISAM tables. # Allocated per thread, if a full scan is needed. MyISAM表用來做全表掃描的緩沖區大小 如果需要一個完整的掃描,就分配給每一個線程 read_buffer_size=64K read_rnd_buffer_size=256K # This buffer is allocated when MySQL needs to rebuild the index in # REPAIR, OPTIMZE, ALTER table statements as well as in LOAD DATA INFILE # into an empty table. It is allocated per thread so be careful with # large settings. 這個緩沖區是分配給:當MYSQL在需要修理,OPTIMZE,修改表結構語句以及導入加載數據 到一個空表時重建索引。它是分配給每個線程,所以在大型設置中要小心使用。 sort_buffer_size=256K #*** INNODB Specific options *** INNODB特殊項 INNODB保存數據目錄 innodb_data_home_dir="E:/MySQL Datafiles/" # Use this option if you have a MySQL server with InnoDB support enabled # but you do not plan to use it. This will save memory and disk space # and speed up some things. #skip-innodb # Additional memory pool that is used by InnoDB to store metadata # information. If InnoDB requires more memory for this purpose it will # start to allocate it from the OS. As this is fast enough on most # recent operating systems, you normally do not need to change this # value. SHOW INNODB STATUS will display the current amount used. InnoDB存儲元數據信息時的額外的內存池。如果需要更多的內存,InnoDB為此它會分配它的操作系統內存。因為在大多數操作系統中,這已經是足夠快的了,所以通常不需要修改這個值。SHOW INNODB STATUS會顯示當前的使用量 innodb_additional_mem_pool_size=2M # If set to 1, InnoDB will flush (fsync) the transaction logs to the # disk at each commit, which offers full ACID behavior. If you are # willing to compromise this safety, and you are running small # transactions, you may set this to 0 or 2 to reduce disk I/O to the # logs. Value 0 means that the log is only written to the log file and # the log file flushed to disk approximately once per second. Value 2 # means the log is written to the log file at each commit, but the log # file is only flushed to disk approximately once per second. 如果設置為1,InnoDB會在每個提交磁盤沖洗事務日志,這提供了完整的ACID的行為. 如果你想安全,並且正在執行一些小操作,你可以設置為0或者2在減少磁盤I / O日志。 #innodb_flush_log_at_trx_commit=1 # The size of the buffer InnoDB uses for buffering log data. As soon as # it is full, InnoDB will have to flush it to disk. As it is flushed # once per second anyway, it does not make sense to have it very large # (even with long transactions). 這個大小用於緩沖InnoDB在緩沖日志數據。一旦它滿了,InnoDB會在磁盤上釋放它。 它無論如何都會一秒緩沖一次,這對於非常大的日志是沒有意義的。(即使有長事務) innodb_log_buffer_size=1M # InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and # row data. The bigger you set this the less disk I/O is needed to # access data in tables. On a dedicated database server you may set this # parameter up to 80% of the machine physical memory size. Do not set it # too large, though, because competition of the physical memory may # cause paging in the operating system. Note that on 32bit systems you # might be limited to 2-3.5G of user level memory per process, so do not # set it too high. InnoDB,不像MyISAM,使用一個緩沖池來緩存的兩個索引和行數據。這個磁盤I / O設置的更大,需要訪問的數據表更少。在專用的數據庫服務器上你可以設置參數高達80%的機器的物理內存大小。不用把它設置的太大,不過,因為在操作系統中競爭的物理內存可能導致內存不夠分。注意,32位系統上的你可能被限制在2 - 3.5g的用戶級內存,所以不要設置的太高。 innodb_buffer_pool_size=83M # Size of each log file in a log group. You should set the combined size # of log files to about 25%-100% of your buffer pool size to avoid # unneeded buffer pool flush activity on log file overwrite. However, # note that a larger logfile size will increase the time needed for the # recovery process. 每個日志文件在日志組裡的大小。你應該將日志文件大約為25% - -100%緩沖池大小合並來避免不必要的緩沖池的緩沖行為覆蓋日志文件。然而,一個大的日志文件將增加復蘇過程的所需時間。 innodb_log_file_size=17M # Number of threads allowed inside the InnoDB kernel. The optimal value # depends highly on the application, hardware as well as the OS # scheduler properties. A too high value may lead to thread thrashing. InnoDB的內核允許多線程。最高性能取決於高的應用程序、硬件以及操作系統。 一個很高的值可能導致線程抖動 innodb_thread_concurrency=8