In this tutorial, we will show you how to install and configure MySQLTuner on your CentOS server. For those of you who didn’t know, MySQLTuner is a script written in Perl that allows you to review a MySQL installation quickly and make adjustments to increase performance and stability. The current configuration variables and status data are retrieved and presented in a brief format along with some basic performance suggestions. It is really easy to use and it is recommended to analyze your Linux VPS regularly in order to get the best performance.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘
sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of MySQLTuner on a CentOS server.
- A server running one of the following operating systems: CentOS Linux or RHEL-based.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for the MySQLTuner script.
non-root sudo useror access to the
root user. We recommend acting as a
non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.
Install MySQLTuner on CentOS
Step 1. First, let’s start by ensuring your system is up-to-date.
sudo yum update sudo yum install perl
Step 2. Enabling the EPEL Repository.
The Extra Packages for Enterprise Linux (EPEL) repository is a community-approved repository that houses additional packages for enterprise Linux. To install MySQLTuner, we first need to enable the EPEL repository. This can be done by executing the following command:
sudo yum install epel-release
Step 2. Installing MySQLTuner on CentOS Linux or RHEL-based.
Download the MySQLTuner script as follows:
After downloading the MySQL Tuner script, you need to make it executable. Run the following command to do so:
chmod +x mysqltuner.pl
To run MySQLTuner, you can execute the command:
As a result, you should get something like this:
-------- Recommendations ----------------------------------------------------- General recommendations: Run OPTIMIZE TABLE to defragment tables for better performance Reduce or eliminate unclosed connections and network issues When making adjustments, make tmp_table_size/max_heap_table_size equal Reduce your SELECT DISTINCT queries which have no LIMIT clause Variables to adjust: query_cache_type (=4) tmp_table_size (> 8M) max_heap_table_size (> 8M)
The report generated by MySQL Tuner will include various sections, such as general recommendations, memory usage, query cache, and more. Each section will include recommendations for improving the performance of your MySQL database. Make sure to read through each section carefully and understand the recommendations before making any changes to your MySQL configuration.
The script recommends adjusting or adding the following variables in the MySQL
my.cnf file. The location of
my.cnf is normal
/etc/mysql/my.cnf depending on the Linux distribution that is installed on your server.
Step 3. Re-run MySQL Tuner.
After implementing the recommended changes to your MySQL configuration, it’s essential to re-run MySQL Tuner to ensure that the changes have improved the performance of your MySQL database.
*Remember to run MySQLTuner after your database has been active for at least 24 hours. Also, take a cautious approach when applying recommendations and regularly update your server and MySQLTuner to benefit from the latest features and security patches.
Congratulations! You have successfully installed MySQLTuner. Thanks for using this tutorial for installing MySQLTuner to optimize your MySQL on the CentOS system. For additional help or useful information, we recommend you check the official MySQLTuner website.