MySQLTuner is a utility that analyzes the statistics of MySQL and issue recommendations for optimizing MySQL server settings.
First you need to install the utility.
Debian/Ubuntu:
apt-get install mysqltuner
CentOS:
yum install mysqltune
For a more accurate granting of the necessary recommendations to optimize MySQL with MySQLTuner must run for at least 24 hours.
For using the utility, run the command:
mysqltuner
Recommendations for optimization you need to make in configuration file of MySQL.
The location of the configuration file my.cnf:
Debian/Ubuntu
/etc/mysql/my.cnf
CentOS:
/etc/my.cnf
After making changes to the file my.cnf need to restart MySQL server:
Debian/Ubuntu:
/etc/init.d/mysql restart
CentOS:
/etc/init.d/mysqld restart