MySQL配置 适用于小内存CentOS

时间:2024-03-13 10:29:18

运行环境

 CentOS 6.5

 MySQL 5.6

购买了一个512M内存VPS服务器,在上面搭建了wordpress运行环境后,MySQL 有时候会被杀掉或者无法启动。

故修改为如下配置

[mysqld]
port            = 3306
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
skip-external-locking
key_buffer_size = 2M
max_allowed_packet = 1M
table_open_cache = 128
sort_buffer_size = 128K
read_buffer_size = 1M
read_rnd_buffer_size = 2M
myisam_sort_buffer_size = 4M
thread_cache_size = 10
query_cache_size= 0M
thread_concurrency = 8
log-bin=mysql-bin
binlog_format=mixed
server-id = 1
character-set-server=utf8
collation-server=utf8_general_ci
key_buffer = 16K
query_cache_limit = 256K
max_allowed_packet = 1M
default-storage-engine=MYISAM
default-tmp-storage-engine=MYISAM
loose-skip-innodb

[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer = 8M
sort_buffer_size = 8M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
[client]
default-character-set=utf8

放弃使用innodb,

修改后重启MySQL,使用top -m 查看内存占用降到76m左右

MySQL配置 适用于小内存CentOS