Skip to content

Instantly share code, notes, and snippets.

@zhakkapong
Forked from Gomah/my.cnf
Created July 4, 2021 08:46
Show Gist options
  • Save zhakkapong/6087b13cfb35ed2862bcdaca5abd0af3 to your computer and use it in GitHub Desktop.
Save zhakkapong/6087b13cfb35ed2862bcdaca5abd0af3 to your computer and use it in GitHub Desktop.
MySQL config for 4 cores/8 threads, 32 GB RAM
# CLIENT
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
# MYSQL SAFE
[mysqld_safe]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
# GENERAL
user = mysql
default_storage_engine = InnoDB
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
explicit_defaults_for_timestamp
# MyISAM
key_buffer_size = 32M
myisam_recover = FORCE,BACKUP
# SAFETY
innodb = FORCE
innodb_strict_mode = 1
max_allowed_packet = 16M
max_connect_errors = 1000000
skip_name_resolve
# BINARY LOGGING
log_bin = /var/log/mysql/mysql-bin
expire_logs_days = 14
sync_binlog = 1
# CACHES AND LIMITS
max_connections = 500
max_heap_table_size = 32M
open_files_limit = 65535
query_cache_type = 0
query_cache_size = 0
table_definition_cache = 4096
table_open_cache = 10240
thread_cache_size = 50
tmp_table_size = 32M
# INNODB
innodb_buffer_pool_size = 26G
innodb_buffer_pool_instances = 4
innodb_flush_method = O_DIRECT
innodb_flush_log_at_trx_commit = 1
innodb_file_per_table = 1
innodb_log_files_in_group = 2
innodb_log_file_size = 512M
# LOGGING
log_error = /var/log/mysql/mysql-error.log
log_queries_not_using_indexes = 1
slow_query_log = 1
slow_query_log_file = /var/log/mysql/mysql-slow.log
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment