Linux下简单优化MySQL,减少内存占用

MySQL 是一个很棒的 open source 数据库引擎,大部分的网站和博客都是由 MySQL 驱动的。MySQL 的默认安装占用的内存资源比较大,优化 MySQL 可以减少内存消耗,把更多的内存省下来留给其他程序。以下方法可以简单减少大约100M内存(相对默认安装的mysql) ==================== centos版本下,不适用mysql5.5以上 在你的/etc/my.cnf里加入以下三行:  skip-locking skip-bdb skip-innodb 

max_connections = 2000

然后重启mysql

对于mysql5.5:

skip-external-locking

 

default-storage-engine=MyISAM
loose-skip-innodb

loose-innodb-trx=0 
loose-innodb-locks=0 
loose-innodb-lock-waits=0 
loose-innodb-cmp=0 
loose-innodb-cmp-per-index=0
loose-innodb-cmp-per-index-reset=0
loose-innodb-cmp-reset=0 
loose-innodb-cmpmem=0 
loose-innodb-cmpmem-reset=0 
loose-innodb-buffer-page=0 
loose-innodb-buffer-page-lru=0 
loose-innodb-buffer-pool-stats=0

对于5.6以上

skip-external-locking
default-storage-engine=MyISAM
default-tmp-storage-engine=MYISAM
loose-skip-innodb

loose-innodb-trx=0 
loose-innodb-locks=0 
loose-innodb-lock-waits=0 
loose-innodb-cmp=0 
loose-innodb-cmp-per-index=0
loose-innodb-cmp-per-index-reset=0
loose-innodb-cmp-reset=0 
loose-innodb-cmpmem=0 
loose-innodb-cmpmem-reset=0 
loose-innodb-buffer-page=0 
loose-innodb-buffer-page-lru=0 
loose-innodb-buffer-pool-stats=0 
loose-innodb-metrics=0 
loose-innodb-ft-default-stopword=0 
loose-innodb-ft-inserted=0 
loose-innodb-ft-deleted=0 
loose-innodb-ft-being-deleted=0 
loose-innodb-ft-config=0 
loose-innodb-ft-index-cache=0 
loose-innodb-ft-index-table=0 
loose-innodb-sys-tables=0 
loose-innodb-sys-tablestats=0 
loose-innodb-sys-indexes=0 
loose-innodb-sys-columns=0 
loose-innodb-sys-fields=0 
loose-innodb-sys-foreign=0 
loose-innodb-sys-foreign-cols=0

 

1 条评论

  1. 老刘

    http://files.directadmin.com/services/all/mysql/my-huge-5.5.cnf

    http://files.directadmin.com/services/all/mysql/my-large-5.5.cnf

    mysql配置文件

此处评论已关闭