How to optimize MySql for 1GB Memory VPS

SSH into Server and login as root

Backup my.cnf

cp /etc/my.cnf /etc/my.cnf.old

pico /etc/my.cnf

replace with this:

[mysqld]
max_connections = 400
key_buffer = 32M
myisam_sort_buffer_size = 32M
join_buffer_size = 1M
read_buffer_size = 1M
sort_buffer_size = 2M
table_cache = 1024
thread_cache_size = 286
interactive_timeout = 25
wait_timeout = 1000
connect_timeout = 10
max_allowed_packet = 16M
max_connect_errors = 10
query_cache_limit = 1M
query_cache_size = 16M
query_cache_type = 1
tmp_table_size = 16M


[mysqld_safe]
open_files_limit = 8192

[mysqldump]
quick
max_allowed_packet = 16M

[myisamchk]
key_buffer = 64M
sort_buffer = 64M
read_buffer = 16M
write_buffer = 16M

local-infile=0

save.

Restart mysql

/etc/rc.d/init.d/mysql restart

Restore old backup
cp /etc/my.cnf.old /etc/my.cnf

/etc/rc.d/init.d/mysql restart

7 thoughts on “How to optimize MySql for 1GB Memory VPS”

  1. Note that table_cache was renamed table_open_cache in MySQL 5.1.3 and is referred to by the new name in newer versions of MySQL.

Leave a Reply

Your email address will not be published. Required fields are marked *