Home > linux > Reducing MySQL memory usage

Reducing MySQL memory usage

My other site, http://www.aqua-mail.com is hosted in Xen virtual machine with 512 MB of RAM.

Of those 512, about 300 were taken by MySQL daemon, causing some swap use.

I was able to get MySQL down from 300 to about 60 megabytes of RAM by doing the following.

Most of my tables were already using MyISAM engine, but there was a couple using InnoDB.

1) Converted the remaining tables from InnoDB to MyISAM, by running this in the PhpMyAdmin SQL window:


ALTER TABLE table_name_here ENGINE=MyISAM;

2) Disabled InnoDB support by creating a new config file in /etc/mysql/conf.d, with this content:


[mysqld]
default-storage-engine = myisam
skip-innodb

The file can have any name you want, as long as it ends with “.cnf“.

3) Restarted MySQL:


service mysql restart

I’m sure InnoDB is a terrific engine, and Oracle had a very good reason for making it the default starting with MySQL 5.5.

However, for a low-memory VPS system, low-traffic web site, avoid swap should probably be a priority.

Advertisements
Categories: linux
  1. No comments yet.
  1. January 26, 2013 at 6:48 am

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s