By default MySQL installs a configuration file with big caches and uses up more memory than is needed on most server setups. If like me you are struggling for free ram you may wish to use MySQL’s my-small.cnf configuration file which is included in the packages documentation folder, usually found at /usr/share/doc/mysql-server-5.0/examples.

Simply backup your existing my.cnf file usually located in /etc/mysql and copy over the my-small.cnf from the examples directory

# mv /etc/mysql/my.cnf /etc/mysql/my.cnf.bak
# cp /usr/share/doc/mysql-server-5.0/examples/my-small.cnf /etc/mysql/my.cnf

Additionally if you do not use the InnoDB or Berkley DB storage engines (if you are not familiar with these, you are most likely using MyISAM by default) make sure you have the following 2 lines in your my.cnf

skip-bdb
skip-innodb

For me, using these options lowers my MySQL memory footprint from about 140MB down to just 30MB.

Here is my version of my.cnf.
my.cnf
This should be usable on most servers desiring a small MySQL memory footprint.

If you liked this article please reccomend it
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • StumbleUpon