How to tune MySQL database running on Centos/RedHat?

There are two linux tuning scripts I would recommend to anyone who wants to tweak MySQL installation for the best possible performance.

One of them is MySQL Tuner Primer with download located at this page:

Another one is called MySQL Tuner which is available for download from following url:

Both of these scripts will basically do the same thing, run a performance test and then output my.cnf changes in order to achieve the best performance.
Please note, that in order to get the good recommendations, your MySQL server should be running for at least 1-2 full days and have enough data.

This is how you install and execute each of these scripts.

First, we need to install BC. This is how you can do this in CentOS/RedHat:

Then download both scripts, execute following commands:

Then execute MySQL Tuner Primer:

Output will look something like this:
9-5-2013 4-30-31 AM

Look at the recommendations!

Now try to run MySQL Tuner:

Output should look like this:
9-5-2013 4-28-18 AM

Again, look at the recommendations and based on output from above scripts adjust my.cnf, then reboot MySQL.