Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to optimize variables in mysql

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces you how to optimize variables in mysql, the content is very detailed, interested friends can refer to, hope to be helpful to you.

[d]

Port = 3306

Server-id = 1

Socket = / tmp/mysql.sock

# avoid external locking of MySQL, reduce the probability of error and enhance stability.

Skip-locking

# prohibit MySQL from parsing DNS for external connections

Skip-name-resolve

# specify the number of possible connections to MySQL

Back_log = 256

# using query buffering

Query_cache_size = 32m

Query_cache_type = 1

# specify the size of the buffer to be used for indexing. For servers with memory around 4GB, this parameter can be set to 256m or 384Mkey_reads / key_read_requests is at least 1rig 100pm 1purl 1000 better.

Key_buffer_size = 256m

# allowed request packet size when a query is executing, a copy of the current query statement also needs to allocate memory for it.

Max_allowed_packet = 4m

# specify the size of the table cache. For machines with 1 GB of memory, the recommended value is 128 ~ 256.

Table_cache = 256K

# the buffer size that can be used for query sorting is exclusive per connection

Sort_buffer_size = 6m

# buffer size that can be used by read query operations is exclusive per connection

Read_buffer_size = 4m

# buffer size that can be used by federated query operations is exclusive per connection

Join_buffer_size = 8m

# buffers required to reorder when the MyISAM table changes

Myisam_sort_buffer_size = 64m

# specify the size of the MySQL query buffer

Query_cache_size = 64m

Tmp_table_size = 256m

# specify the maximum number of connection processes allowed by MySQL

Max_connections = 768

Max_connect_errors = 10000000

# specify the maximum connection time for a request

Wait_timeout = 10

Interactive_timeout = 10

# the value of this parameter is the number of server logical CPU × 2

Thread_concurrency = 8

# number of reusable threads in the cache

Thread_cache = 256

Thread_cache_size = 64

# Stack size of each thread

Thread_stack = 256K

# record slow queries, and then optimize slow queries one by one

Log-slow-queries = slow.log

Long_query_time = 2

Log-queries-not-using-indexes

# turn off unwanted table types, and do not add this if you need it

Skip-innodb

Skip-bdb

# set the table created by default to be InnoDB type

Default-table-type = innodb

# innodb home directory

Innodb_data_home_dir = / mysql_data

# controls the buffers allocated to sort Innodb internal data dictionaries.

Innodb_additional_mem_pool_size = 50m

# innodb specifies the data file name and size

Innodb_data_file_path = ibdata1:20G;ibdata2:200M:autoextend

# set the buffer pool size to 50-80% of your main memory size

Innodb_buffer_pool_size = 70m

# set the log file size to about 25% of the buffer pool (buffer pool) size

Innodb_log_file_size = 20m

# buffer size before InnoDB writes logs to log disk files

Innodb_log_buffer_size = 4m

# means that the log has been written to disk before the transaction is committed, the transaction can run longer, and the ability to repair after a service crash

Innodb_flush_log_at_trx_commit = 1

On how to optimize variables in mysql to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report