very low memory mysql 5 my.cnf configuration

on VPS server with very limited memory it is good to tweak mysql5. In /etc/mysql/my.cnf

# Main MySQL server options
port = 3306
socket = /var/run/mysqld/mysqld.sock

# No locking at all!

# Set internal buffers, caches and stacks very low
key_buffer = 16K
max_allowed_packet = 16K
table_cache = 1
sort_buffer_size = 16K
read_buffer_size = 16K
read_rnd_buffer_size = 1K
net_buffer_length = 1K
thread_stack = 16K

# Don't listen on a TCP/IP port at all.
# Will still work provided all access is done via localhost
server-id = 1

# Skip Berkley and Inno DB types

# Set the query cache low
query_cache_limit = 1048576
query_cache_size = 1048576
query_cache_type = 1

# Set various memory limits very low, disable memory-hogging extras
max_allowed_packet = 16K
key_buffer = 16K
sort_buffer_size = 16K
key_buffer = 16K
sort_buffer_size = 16K

More info


Published by


Different. In a good way

One thought on “very low memory mysql 5 my.cnf configuration”

  1. Thanks!

    Another tip for Apache 1.3 built with libmm: it might try and get all the available shared memory, sysctl -w kernel.shmmax=4194304 (and fixating it in /etc/sysctl.conf) might help.

    A bunch of my VEs got pretty well down on virtual memory sizings, even given the usage of nginx as static/frontend httpd and reverse proxy 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s