Using MySQLTunner
MySQLTuner is a perl script that check your MySQL installation and suggest you changes based on your usage. To optimize MySQL, run
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl chmod 755 mysqltuner.pl ./mysqltuner.pl
Follow the suggestions it shows.
See MySQL