0x0034's Blog.

MySQL 自建配置

字数统计: 92阅读时长: 1 min
2022/11/27

MySQL 自用优化配置

适用于4c8g 机器.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
[mysqld]
sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
skip_ssl
ignore-db-dir=lost+found
datadir=/var/lib/mysql
socket=/tmp/mysql.sock
skip-host-cache
binlog_format=ROW
default_storage_engine=InnoDB
innodb_flush_log_at_trx_commit = 0
innodb_flush_method = O_DIRECT
innodb_file_per_table = 1
innodb_thread_concurrency = 0
innodb_max_dirty_pages_pct = 75
innodb_autoinc_lock_mode=2
bind_address = 0.0.0.0
innodb_buffer_pool_size = 5G
character-set-server = utf8mb4
max_connections = 2048
max_connect_errors=50000
wait_timeout=7200
interactive_timeout = 7200
thread_cache_size = 256
table_open_cache = 2000
max_allowed_packet = 256M
slow_query_log=1
long_query_time=0.2
log_output=FILE
log_error=/var/lib/mysql/mysql-error.log
slow_query_log_file=/var/lib/mysql/mysql-slow.log
log-queries-not-using-indexes = 0
sort_buffer_size=512k
read_rnd_buffer_size=512k
max_length_for_sort_data = 16k
join_buffer_size=512k
tmp_table_size = 2M
max_heap_table_size = 2M
query_cache_size=0
query_cache_type=OFF
innodb_lock_wait_timeout = 5
innodb_deadlock_detect=on
innodb_read_io_threads = 4
innodb_write_io_threads = 4
CATALOG
  1. 1. MySQL 自用优化配置