Optimize MySQL my.cnf

By | 2011/01/01

If you are using MySQL, it can help to optimize MySQL according to how much ram you have on your server.

Make these changes by editing: /etc/mysql/my.cnf

Ubuntu and most all distros include example config file settings based on your available ram. These examples are generally located in:

/usr/share/doc/mysql-server-5.1/examples/ ->
my-small.cnf.gz
my-medium.cnf.gz
my-large.cnf.gz
my-huge.cnf.gz

my-small.cnf is good for systems with extremely small memory (under 64MB!).
my-medium.cnf is good for systems up to 128MB of memory.
my-large.cnf is good for systems with 512MB of memory.
my-huge.cnf is good for systems with 1-2GB of memory or more, with most dedicated for mysql.


If desired, there are some performance analysis tools you can run, such as mysqltuner.pl and tuning-primer.sh.

In general it is probably good to keep mysql’s total memory footprint under 60% of total system memory. A good way to check this is to use this handy tool: http://www.omh.cc/mycnf.

Sweet!