对于小内存的vps来说,内存资源十分宝贵,有时设置不当或没有优化就会平白浪费很多内存,这就需要我们对vps进行优化了,这里主要说的是mysql的优化,设置优化后效果还是明显的。
mysql的配置文件: /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
skip-bdb
skip-innodb
skip-networking
server-id = 1
key_buffer = 256K
max_allowed_packet=1M
thread_stack = 64K
table_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 64K
query_cache_limit=256K
query_cache_size = 2M
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/my
别优化了 会导致MYSQL启动失败的