1. 程式人生 > >MySQL——配置檔案(my.ini)

MySQL——配置檔案(my.ini)

# CLIENT SECTION
# ----------------------------------------------------------------------
[client]
#password =1234

# pipe
# socket=mysql
# 設定mysql客戶端連線服務端時預設使用的埠
port=3306

default-character-set=utf8
[mysql]
port=3306
# 設定mysql客戶端預設字符集
default-character-set=utf8


# SERVER SECTION
# ----------------------------------------------------------------------
[mysqld]
# mysql服務端預設監聽(listen on)的TCP/IP埠
port=3306

# 基準路徑,其他路徑都相對於這個路徑;即MySQL的安裝路徑
basedir="D:\MySQL"

# mysql資料庫檔案所在目錄
datadir="D:\Mysql\data"

# 服務端使用的字符集預設為8位元編碼的utf-8字符集
character-set-server=utf8

# 建立新表時將使用的預設儲存引擎
default-storage-engine=INNODB

# SQL模式為strict模式
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

# General and Slow logging.
log-output=NONE
general-log=0
general_log_file="WANGZHANGJIE.log"
slow-query-log=0
slow_query_log_file="WANGZHANGJIE-slow.log"
long_query_time=10

# Error Logging.
log-error="WANGZHANGJIE.err"

# mysql伺服器支援的最大併發連線數(使用者數)。但總會預留其中的一個連線給管理員使用超級許可權登入,
# 即使連線數目達到最大限制。如果設定得過小而使用者比較多,會經常出現“Too many connections”錯誤。
max_connections=100

# 查詢快取大小,用於快取SELECT查詢結果。如果有許多返回相同查詢結果的SELECT查詢,並且很少改變表,
# 可以設定query_cache_size大於0,可以極大改善查詢效率。而如果表資料頻繁變化,就不要使用這個,會適得其反
query_cache_size=0

# 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_open_cache=2000

# 記憶體中的每個臨時表允許的最大大小。如果臨時表大小超過該值,臨時表將自動轉為基於磁碟的表(Disk Based Table)。
tmp_table_size=20M

# 快取的最大執行緒數。當客戶端連線斷開時,如果客戶端總連線數小於該值,則處理客戶端任務的執行緒放回快取。
# 在高併發情況下,如果該值設定得太小,就會有很多執行緒頻繁建立,
# 執行緒建立的開銷會變大,查詢效率也會下降。一般來說如果在應用端有良好的多執行緒處理,這個引數對效能不會有太大的提高。
thread_cache_size=9

# 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=39M


# Key Buffer大小,用於快取MyISAM表的索引塊。決定資料庫索引處理的速度(尤其是索引讀)
key_buffer_size=8M


# 用於對MyISAM表全表掃描時使用的緩衝區大小。針對每個執行緒進行分配(前提是進行了全表掃描)。
# 進行排序查詢時,MySql會首先掃描一遍該緩衝,以避免磁碟搜尋,提高查詢速度,
# 如果需要排序大量資料,可適當調高該值。但MySql會為每個客戶連線發放該緩衝空間,
# 所以應儘量適當設定該值,以避免記憶體開銷過大。
read_buffer_size=64K
read_rnd_buffer_size=256K


# connection級引數(為每個執行緒配置),500個執行緒將消耗500*256K的sort_buffer_size。
sort_buffer_size=256K


# InnoDB用於儲存元資料資訊的記憶體池大小,一般不需修改
innodb_additional_mem_pool_size=2M


# 事務相關引數,如果值為1,則InnoDB在每次commit都會將事務日誌寫入磁碟(磁碟IO消耗較大),
# 這樣保證了完全的ACID特性。而如果設定為0,則表示事務日誌寫入記憶體log和記憶體log寫入磁碟的頻率都為1次/秒。
# 如果設為2則表示事務日誌在每次commit都寫入記憶體log,但記憶體log寫入磁碟的頻率為1次/秒。


innodb_flush_log_at_trx_commit=1


# InnoDB日誌資料緩衝大小,如果緩衝滿了,就會將緩衝中的日誌資料寫入磁碟(flush)。
# 由於一般至少都1秒鐘會寫一次磁碟,所以沒必要設定過大,即使是長事務。
innodb_log_buffer_size=1M

# InnoDB使用緩衝池來快取索引和行資料。該值設定的越大,則磁碟IO越少。一般將該值設為實體記憶體的80%。
innodb_buffer_pool_size=97M

# 每一個InnoDB事務日誌的大小。一般設為innodb_buffer_pool_size的25%到100%
innodb_log_file_size=48M

# InnoDB核心最大併發執行緒數
innodb_thread_concurrency=9

# The increment size (in MB) for extending the size of an auto-extend InnoDB system tablespace file when it becomes full.
innodb_autoextend_increment=64M

# The number of regions that the InnoDB buffer pool is divided into.
# For systems with buffer pools in the multi-gigabyte range, dividing the buffer pool into separate instances can improve concurrency,
# by reducing contention as different threads read and write to cached pages.
innodb_buffer_pool_instances=8

# Determines the number of threads that can enter InnoDB concurrently.
innodb_concurrency_tickets=5000

# Specifies how long in milliseconds (ms) a block inserted into the old sublist must stay there after its first access before
# it can be moved to the new sublist.
innodb_old_blocks_time=1000

# It specifies the maximum number of .ibd files that MySQL can keep open at one time. The minimum value is 10.
innodb_open_files=300

# When this variable is enabled, InnoDB updates statistics during metadata statements.
innodb_stats_on_metadata=0

# When innodb_file_per_table is enabled (the default in 5.6.6 and higher), InnoDB stores the data and indexes for each newly created table
# in a separate .ibd file, rather than in the system tablespace.
innodb_file_per_table=1

# Use the following list of values: 0 for crc32, 1 for strict_crc32, 2 for innodb, 3 for strict_innodb, 4 for none, 5 for strict_none.
innodb_checksum_algorithm=0

# The number of outstanding connection requests MySQL can have.
# This option is useful when the main MySQL thread gets many connection requests in a very short time.
# It then takes some time (although very little) for the main thread to check the connection and start a new thread.
# The back_log value indicates how many requests can be stacked during this short time before MySQL momentarily
# stops answering new requests.
# You need to increase this only if you expect a large number of connections in a short period of time.
back_log=70


# If this is set to a nonzero value, all tables are closed every flush_time seconds to free up resources and
# synchronize unflushed data to disk.
# This option is best used only on systems with minimal resources.
flush_time=0

# The minimum size of the buffer that is used for plain index scans, range index scans, and joins that do not use
# indexes and thus perform full table scans.
join_buffer_size=256K

# The maximum size of one packet or any generated or intermediate string, or any parameter sent by the
# mysql_stmt_send_long_data() C API function.
max_allowed_packet=4M

# If more than this many successive connection requests from a host are interrupted without a successful connection,
# the server blocks that host from performing further connections.
max_connect_errors=100

# Changes the number of file descriptors available to mysqld.
# You should try increasing the value of this option if mysqld gives you the error "Too many open files".
open_files_limit=4110

# Set the query cache type. 0 for OFF, 1 for ON and 2 for DEMAND.
query_cache_type=0

# If you see many sort_merge_passes per second in SHOW GLOBAL STATUS output, you can consider increasing the
# sort_buffer_size value to speed up ORDER BY or GROUP BY operations that cannot be improved with query optimization
# or improved indexing.
sort_buffer_size=256K

# The number of table definitions (from .frm files) that can be stored in the definition cache.
# If you use a large number of tables, you can create a large table definition cache to speed up opening of tables.
# The table definition cache takes less space and does not use file descriptors, unlike the normal table cache.
# The minimum and default values are both 400.
table_definition_cache=1400

# Specify the maximum size of a row-based binary log event, in bytes.
# Rows are grouped into events smaller than this size if possible. The value should be a multiple of 256.
binlog_row_event_max_size=8K

# If the value of this variable is greater than 0, a replication slave synchronizes its master.info file to disk.
# (using fdatasync()) after every sync_master_info events.
sync_master_info=10000

# If the value of this variable is greater than 0, the MySQL server synchronizes its relay log to disk.
# (using fdatasync()) after every sync_relay_log writes to the relay log.
sync_relay_log=10000

# If the value of this variable is greater than 0, a replication slave synchronizes its relay-log.info file to disk.
# (using fdatasync()) after every sync_relay_log_info transactions.
sync_relay_log_info=10000