MySQL Performance configuration optimization

Source: Internet
Author: User

To modify the MySQL configuration file my.cnf, the contents are as follows:

[Mysqld]
Datadir=/data/mysql/data
Socket=/var/lib/mysql/mysql.sock
User=mysql
# Disabling Symbolic-links is recommended to prevent assorted security risks
Symbolic-links=0
# Set the default character set to avoid the inability to enter Chinese
Character_set_server=utf8
init_connect= ' SET NAMES UTF8 '
# setting table names is case insensitive
Lower_case_table_names=1
# Disable MySQL for DNS resolution of external connections 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 will not
Processing connection Requests
Skip-name-resolve
# KEY_BUFFER_SIZE Specifies the buffer size to use for the index, increasing it to get better index processing performance. The parameter can be set to 256M or 384M for a server that has around 4GB. Note: The value of this parameter setting is too large instead of the server as a whole
Reduced efficiency
Key_buffer_size = 128M
# Limit the size of packets accepted by the server, which has a significant impact on large inserts and updates
Max_allowed_packet = 4M
Thread_stack = 256K
# The size of the buffer that can be used when querying the sort. Note: The allocated memory for this parameter is per-connection exclusive, and if there are 100 connections, then the actual allocated total sort buffer size is 100x6 = 600MB. Therefore, for the internal presence of about 4GB
Server recommended set to 6-8m
Sort_buffer_size = 6M
# The size of the buffer that can be used when querying the sort. Note: The allocated memory for this parameter is per-connection exclusive, and if there are 100 connections, then the actual allocated total sort buffer size is 100x6 = 600MB. Therefore, for the internal presence of about 4GB
Server recommended set to 6-8m
Read_buffer_size = 24M
# 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
Join_buffer_size = 8M
# The larger the physical memory, the greater the setting. Default is 2402, set to 512-1024 best
Table_cache = 512
# default is 256K
Thread_cache_size = 64
# default is 60M
Query_cache_size = 64M
# Specifies the maximum number of connection processes allowed by MySQL. If the too many connections error is frequently encountered when accessing the forum, you need to increase the parameter value
max_connections = 100
# Specify the maximum connection time for a request, for a server with about 4GB memory can be set to 5-10
Wait_timeout = 10
# This parameter values the number of server logical CPUs
Thread_concurrency = 4
Innodb_thread_concurrency=8
#物理内存越大, the larger the setting. Default is 2402, set to 512-1024 best
table_cache=512
#默认为2M
innodb_additional_mem_pool_size=4m
#设置为0就是等到innodb_log_buffer_size列队满后再统一储存, default is 1
Innodb_flush_log_at_trx_commit=1

Innodb_log_buffer_size=2m

[Mysqld_safe]
Log-error=/var/log/mysqld.log
Pid-file=/var/run/mysqld/mysqld.pid

[Client]
Socket=/var/lib/mysql/mysql.sock

MySQL Performance configuration optimization

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.