The following is from http://www.jb51.net/article/48082.htm
[Client]port = 3306socket =/tmp/mysql.sock[mysqld]port = 3306socket =/tmp/mysql.sockbasedir =/usr/local/mysqldatadir = /data/mysqlpid-file =/data/mysql/mysql.piduser = mysqlbind-address = 0.0.0.0server-id = 1 #表示是本机的序号为1, Generally speaking is the meaning of master skip-name-resolve# disable the DNS resolution of external connections by MySQL and use this option to eliminate the time for DNS resolution for MySQL. However, it is important to note that if this option is turned on, all remote host connection authorizations will use IP address mode, otherwise MySQL cannot properly handle connection requests #skip-networkingback_log = 600# MySQL can have the number of connections. When the primary MySQL thread gets very many connection requests in a very short time, this works, # then the main thread takes some time (albeit very short) to check the connection and start a new thread. The Back_log value indicates how many requests can be present in the stack for a short period of time before MySQL temporarily stops answering a new request. # If you expect to have a lot of connections in a short period of time, you need to add it. That is, if the MySQL connection data reaches max_connections, the new request will be present in the stack, # to wait for a connection to release the resource, the number of that stack is back_log, and if the number of waiting connections exceeds back_log, the connection resource will not be granted. In addition, this value (Back_log) is limited to the size of your operating system's listening queue for incoming TCP/IP connections. # your operating system has its own limit on this queue size (you can check your OS documentation to find out the maximum value of this variable), trying to set the limit of Back_log above your operating system will be invalid. max_connections = 1000# MySQL Maximum number of connections, if the server's concurrent connection request volume is large, it is recommended to increase this value, so that the number of parallel connections, of course, this is based on the machine can support the case, because if the number of connections, the more When MySQL provides a connection buffer for each connection, the more memory is spent, so adjust the value appropriately to not blindly increase the value. The ' conn% ' wildcard character can be used to view the number of connections in the current state to decide the size of the value. Max_connect_errors = 6000# for the same host, if there is more than the value of the parameterIf the number of interrupts is incorrect, the host will be blocked from connecting. To unblock the host, execute: FLUSH host. Open_files_limit = 65535# mysql Open file descriptor limit, default minimum 1024, when Open_files_limit is not configured, compare max_connections*5 and Ulimit-n values, Which big use which, # when Open_file_limit is configured, compare the value of Open_files_limit and Max_connections*5, which is big with which. Table_open_cache = 128# MySQL reads some data into the Table_open_cache cache every time a table is opened, and when MySQL cannot find the appropriate information in this cache, it will go to the disk. The default value 64# assumes that the system has 200 concurrent connections, you need to set this parameter to 200*n (N is the number of file descriptors required for each connection); # when the Table_open_cache is set to a large size, if the system does not handle so many file descriptors, then the client fails, Connection not on max_allowed_packet = 4m# accepted packet size; it is safe to increase the value of this variable because additional memory is allocated only when needed. For example, MYSQLD will allocate more memory only if you issue a long query or if mysqld must return a large result row. # This variable takes a smaller default value as a precaution to capture error packets between the client and server, and to ensure that memory overflows are not caused by accidental use of large packets. Binlog_cache_size = 1m# A transaction that, when not committed, logs the resulting log to the cache, and persists the log to disk when the transaction submission needs to be committed. The default binlog_cache_size size 32kmax_heap_table_size = 8m# Defines the size of the memory table that the user can create. This value is used to calculate the maximum row value for the memory table. This variable supports dynamically changing the heap (stack) table buffer size of tmp_table_size = 16m# MySQL. All unions are completed within a DML instruction, and most unions can be done without a temporary table. # Most temporary tables are memory-based (HEAP) tables. Temporary tables with large record lengths (the and the length of all columns) or tables containing BLOB columns are stored on the hard disk. # If an internal heap (stacked) table is larger than Tmp_table_size,mysql, you can automatically put the heap table in memory as neededInstead, the MyISAM table is based on the hard disk. You can also increase the size of the staging table by setting the Tmp_table_size option. In other words, if the value is raised, MySQL will increase the size of the heap, which can increase the speed of the join query read_buffer_size = 2m# MySQL reads the buffer size. A request to sequentially scan a table allocates a read-in buffer, and MySQL allocates a memory buffer for it. The read_buffer_size variable controls the size of this buffer. # If the sequential scan requests to the table are very frequent and you think that frequent scans are going too slowly, you can improve their performance by increasing the value of the variable and the memory buffer size read_rnd_buffer_size = 8m# MySQL's random read buffer size. When rows are read in any order (for example, in sort order), a random read buffer is allocated. When you sort a query, # MySQL scans the buffer first to avoid disk searches, improve query speed, and, if you need to sort large amounts of data, raise the value appropriately. However, MySQL will issue this buffer space for each client connection, so it should be as appropriate to set this value to avoid excessive memory overhead sort_buffer_size = 8m# MySQL performs sorting using the buffer size. If you want to increase the speed of the order by, first see if you can let MySQL use the index instead of the extra sort stage. # if not, you can try increasing the size of the sort_buffer_size variable join_buffer_size = 8m# The buffer size that can be used by the union query operation, as with Sort_buffer_size, The allocated memory for this parameter is also per connection exclusive thread_cache_size = 8# This value (default 8) means that the number of threads stored in the cache can be re-used, and if there is room in the cache when disconnected, then the client thread will be placed in the cache, # if the thread is re-requested, Then the request will be read from the cache, if the cache is empty or a new request, then the thread will be recreated, and if there are many new threads, # Adding this value can improve system performance. By comparing the variables of the connections and threads_created states, You can see the effect of this variable. (–> indicates the value to adjust) # According to the physical memory setting rules are as follows: # 1g-> 8# 2g-> 16# 3g-> 32# greater than 3g-> 64query_cache_size = 8m#mysql query buffer size (from 4.0.1 start, MySQL provides a query buffering mechanism) using query buffering, MySQL willThe SELECT statement and query results are stored in the buffer, and the result is read directly from the buffer for the same SELECT statement (case-sensitive) in the future. Depending on the MySQL user manual, the use of query buffering can be up to 238% efficient. # By checking the status value ' qcache_% ', you can know whether the query_cache_size setting is reasonable: If the value of Qcache_lowmem_prunes is very large, it indicates that there is often insufficient buffering, # If the value of Qcache_hits is also very large, It indicates that the query buffer is used very frequently, the buffer size needs to be increased, and if the value of qcache_hits is small, it indicates that your query repetition rate is very low, # in this case the use of query buffering will affect efficiency, then you can consider not query buffering. In addition, adding sql_no_cache in the SELECT statement can explicitly indicate that the query buffer is not used Query_cache_limit = 2m# Specifies the buffer size that a single query can use, the default 1mkey_buffer_size = 4m# Specifies the buffer size to use for the index, increasing the index (for all reads and multiple writes) that can be better processed, to the extent that you can afford it. If you make it too big, the system will start to change pages and really become slow. The parameter can be set to 384M or 512M for a server that has around 4GB. Check the status values key_read_requests and key_reads,# to see if the Key_buffer_size setting is reasonable. The proportional key_reads/key_read_requests should be as low as possible, # at least 1:100,1:1000 better (the above status values can be obtained using the show status like ' key_read% '). Note: This parameter value setting is too large to be the overall efficiency of the server decreases Ft_min_word_len = 4# word length, default 4transaction_isolation = repeatable-read# MySQL supports 4 transaction isolation levels, They are: # read-uncommitted, read-committed, Repeatable-read, serializable.# if not specified, MySQL defaults to use Repeatable-read, Oracle default is Read-committedlog_bin = Mysql-binbinlog_format = Mixedexpire_logs_days = #超过30天的binlog删除log_error =/dAta/mysql/mysql-error.log #错误日志路径slow_query_log = 1long_query_time = 1 #慢查询时间 more than 1 seconds for slow query slow_query_log_file =/data/ Mysql/mysql-slow.logperformance_schema = 0explicit_defaults_for_timestamp#lower_case_table_names = 1 # Case-insensitive skip-external-locking #MySQL选项以避免外部锁定. This option is turned on by default Default-storage-engine = InnoDB #默认存储引擎innodb_file_per_table = # InnoDB is a stand-alone tablespace pattern, and each table in each database generates a data space # The advantages of a standalone table space: # 1. Each table has a self-contained table space. # 2. The data and indexes for each table will exist in the table space themselves. # 3. You can implement a single table to move through different databases. # 4. The space can be recycled (except for the drop table operation, the empty garbage collector) # Disadvantage: # single table increased too large, such as more than 100g# conclusion: # shared tablespace has few advantages in insert operations. Others do not have a separate table space to perform well. When you enable a stand-alone tablespace, make reasonable adjustments: Innodb_open_filesinnodb_open_files = 500# restricts the data of the table that InnoDB can open, if the table in the library is particularly numerous, increase this. This value defaults to 300innodb_buffer_pool_size = 64m# InnoDB uses a buffer pool to hold indexes and raw data, unlike myisam.#, where you set the larger the amount of disk I/O you need to access the data in the table. # On a standalone database server, you can set this variable to the server physical memory size of the 80%# do not set too large, otherwise, due to the competition of physical memory may cause the operating system to break the page. # Note on 32-bit systems you may be limited to 2-3.5g user-level memory limits for each process, # So don't set it too high. innodb_write_io_threads = 4innodb_read_io_threads = 4# innodb use a background thread to process read/write I/O (input and output) requests on the data page, depending on the number of CPU cores you have changed, default is 4 # Note: These two parameters do not support dynamic changes, you need to add this parameter to the MY.CNF, after modifying the MySQL service, allow the range of values from 1-64innodb_thread_concurrency = 0# default setting of 0, indicating no limit concurrency, here is recommended to set to 0, better to play CPU multi-core processing capacity, Increase concurrency innodb_purge_threads = # InnoDB cleanup is a class of operations that periodically reclaim useless data. In previous releases, the purge operation was part of the main thread, which meant that it could clog other database operations at runtime. # Starting with the mysql5.5.x version, the operation runs on a separate thread and supports more concurrent numbers. The user can set the innodb_purge_threads configuration parameter to select whether the purge operation uses a single-#-alone thread, the parameter is set to 0 by default (without using a separate thread), and a separate purge thread is used when set to 1. Recommended for 1innodb_flush_log_at_trx_commit = 0: If the Innodb_flush_log_at_trx_commit value is 0,log buffer, the log file is written to disk per second, No action is taken when committing the transaction (execution is performed by the MySQL master thread. # Redo log buffers are written to the disk's redo log file (REDO log) every second in the main thread. The default log file is ib_logfile0,ib_logfile1# 1, regardless of whether the transaction has been committed): When set to the default value of 1, log buffer is written to the log every time a transaction is committed. # 2: If set to 2, each commit transaction will write the log, but will not perform the brush operation. The log file is brushed on a per-second schedule. Note that there is no guarantee that 100% per second will be brushed to disk, depending on the scheduling of the process. # each time a transaction commits, the data is written to the transaction log, where the write is only called the file system's write operation, and the file system is cached, so this write does not guarantee that the data has been written to the physical disk # default value of 1 is to ensure complete acid. Of course, you can set this configuration to a value other than 1 in exchange for higher performance, but you will lose 1 seconds of data when the system crashes. # set to 0, when the mysqld process crashes, it loses the last 1 seconds of the transaction. Set to 2, the last 1 seconds of data will be lost only if the operating system crashes or loses power. InnoDB will ignore this value when doing a recovery. # summary # Set to 1 is certainly the safest, but the performance page is the worst (as opposed to the other two parameters, but not unacceptable). If the data consistency and integrity requirements are not high, can be set to 2, if only the mostPerformance, such as high concurrent write log servers, set to zero for higher performance innodb_log_buffer_size = 2m# This parameter determines the amount of memory used by the log files, in M. Larger buffers can improve performance, but unexpected failures will cause data loss. MySQL developer recommended setting to 1-8m between innodb_log_file_size = 32m# This parameter determines the size of the data log file, larger settings can improve performance, but also increases the time required to recover the failed database Innodb_log_files_in_ Group = 3# to improve performance, MySQL can write log files to multiple files in a circular fashion. Recommended setting to 3innodb_max_dirty_pages_pct = 90# InnoDB The main thread flushes the data in the cache pool so that the dirty data scale is less than 90%innodb_lock_wait_timeout = 120 # The InnoDB transaction can wait for a locked timeout number of seconds before being rolled back. InnoDB automatically detects the transaction deadlock in its own locking table and rolls back the transaction. InnoDB Use the Lock tables statement to notice the locking settings. The default value is 50 seconds bulk_insert_buffer_size = 8m# BULK Insert cache size, this parameter is for MyISAM storage engine. For increased efficiency when inserting 100-1000+ records at once. The default value is 8M. Can be doubled to the size of the data volume. Myisam_sort_buffer_size = 8m# MyISAM Sets the size of the buffer used when the table is restored, when it is sorted in the repair table or created index or ALTER TABLE procedure MyISAM Index Allocation Buffer myisam_max_sort_file_size = 10g# If the temporary file becomes more than the index, do not use the Quick Sort index method to create an index. Note: This parameter is given as a byte myisam_repair_threads = # If the value is greater than 1, MyISAM table indexes are created in parallel in repair by sorting (each index is in its own line range) interactive_ Timeout = The number of seconds that the 28800# server waits for activity before closing the interactive connection. The interactive client is defined as a client that uses the Client_interactive option in Mysql_real_connect (). Default value: 28,800 seconds (8 hours) Wait_timeout = 28800# Server closes the non-interactive connectionThe number of seconds before the wait activity. When a thread starts, the session Wait_timeout value is initialized based on the global Wait_timeout value or global interactive_timeout value, # depends on the client type (the connection option by Mysql_real_connect () Client_ Interactive definition). Parameter default value: 28,800 seconds (8 hours) # The maximum number of connections supported by the MySQL server is capped, because each connection is built to consume memory, so we want the client to disconnect and free up memory when connecting to MySQL server after the corresponding operation has been processed. If your MySQL server has a large number of idle connections, they will not only consume memory in vain, but if the connection continues to accumulate and continue to open, # will eventually reach the MySQL server connection limit number, which will be reported ' too many connections ' error. For the value setting of wait_timeout, it should be judged according to the operation condition of the system. # After the system has been running for a period of time, you can see the current system connection status through the show Processlist command, if you find a large number of sleep status of the connection process, then the parameter setting is too large, # can be adjusted to the appropriate smaller. To set Interactive_timeout and wait_timeout at the same time will not take effect. [Mysqldump]quickmax_allowed_packet = 16M #服务器发送和接受的最大包长度 [myisamchk]key_buffer_size = 8msort_buffer_size = 8Mread_ Buffer = 4mwrite_buffer = 4M
MySQL Configuration instructions