Skip to content

Instantly share code, notes, and snippets.

@alexanderscott
Created October 16, 2015 04:46
Show Gist options
  • Save alexanderscott/9ab6b18bc999b8f0add2 to your computer and use it in GitHub Desktop.
Save alexanderscott/9ab6b18bc999b8f0add2 to your computer and use it in GitHub Desktop.
MySQL config for lower memory usage (for 2gb droplet)
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
#datadir = /usr/local/mysql/data
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
explicit_defaults_for_timestamp
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
log-error = /var/log/mysql/error.log
# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
!includedir /etc/mysql/conf.d/
# MEDIUM-LOW MEMORY USE (for 2g RAM)
innodb_buffer_pool_size = 64M
innodb_log_buffer_size=512K
query_cache_size=1M
max_connections=50
key_buffer_size=4388608
#thread_cache_size=0
#host_cache_size=0
innodb_ft_cache_size=4000000
innodb_ft_total_cache_size=420000000
thread_stack=162144
sort_buffer_size=162144
read_buffer_size=81072
read_rnd_buffer_size=162144
max_heap_table_size=8777216
tmp_table_size=8777216
bulk_insert_buffer_size=4388608
join_buffer_size=162144
net_buffer_length=16384
innodb_sort_buffer_size=6K
binlog_cache_size=8K
binlog_stmt_cache_size=8K
# VERY LOW MEMORY USE (for < 1g RAM)
#innodb_buffer_pool_size=10M
#innodb_log_buffer_size=256K
#query_cache_size=0
#max_connections=50
#key_buffer_size=8
#thread_cache_size=0
#host_cache_size=0
#innodb_ft_cache_size=1600000
#innodb_ft_total_cache_size=32000000
# per thread or per operation settings
#thread_stack=131072
#sort_buffer_size=32K
#read_buffer_size=8200
#read_rnd_buffer_size=8200
#max_heap_table_size=16K
#tmp_table_size=1K
#bulk_insert_buffer_size=0
#join_buffer_size=128
#net_buffer_length=1K
#innodb_sort_buffer_size=64K
#settings that relate to the binary log (if enabled)
#binlog_cache_size=4K
#binlog_stmt_cache_size=4K
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment