MySQLTuner is a Perl script that will analyze the performance of MySQL / MariaDB databases, and from the results of this analysis, MySQL Tuner will provide recommendations on which variables should be increased or decreased, in order to increase performance. That way, we can “tuning” the my.cnf file so that the MySQL / MariaDB database server performance is optimal and works more efficiently.
First of all we download the MySQLTuner file first with the command:
Then we first chmod it so it can run:
chmod + x mysqltuner.pl
Then we run MySQLTuner with the command:
NOTES: You must be logged in as root to run the above command.
The output of the above command is as follows:
server1: ~ # ./mysqltuner.pl >> MySQLTuner 0.9.8 - Major Hayden
>> Bug reports, feature requests, and downloads at https://mysqltuner.com/ >> Run with '--help' for additional options and output filtering Please enter your MySQL administrative login: 16M) tmp_table_size (> 32M) max_heap_table_size (> 16M) table_cache (> 64) server1: ~ #
Look at the bottom of the output that says “Recommendations“, Where are the recommendations and variables that you should change to improve MySQL / MariaDB performance.
my.cnf at location
/etc/mysql/my.cnf and change the variables as recommended. When finished restart MySQL / MariaDB with the command
mysql service restart
Periodically check the performance of MySQL / MariaDB with MySQLTuner, at least 24 hours you run this script.