MySQLTuner reads a database server’s settings and activity counters and suggests areas to investigate. It can help an administrator review MySQL or MariaDB performance, but its suggestions need to be checked against the actual workload.
Prepare the review
You need a supported database server, Perl and authorised access to the statistics required by the tool. Check the current MySQLTuner release’s privilege requirements instead of assuming operating system root access automatically grants database access.
Collect representative workload data. The project recommends at least 24 hours of database uptime; counters immediately after a restart are not a reliable basis for tuning.
Install a suitable version
On supported Debian or Ubuntu systems, a distribution package may be available:
sudo apt update
apt show mysqltuner
sudo apt install mysqltunerCheck its version and compatibility. Distribution packages may lag behind the current upstream release.
For another platform or a newer release, obtain the files from the official MySQLTuner project. Verify and review the release before running it. Do not add an unrelated repository or run an unchecked moving script as root merely to obtain the command.
Run the review
For the installed package:
mysqltunerFor a downloaded and reviewed release:
perl mysqltuner.plUse the authentication method supported by your installation and keep passwords out of shell history. Protect saved reports, which can contain sensitive server details.
Evaluate the recommendations
Review memory estimates, connection usage, temporary tables, storage engines and query information. Match each recommendation to the database version and available server resources.
MySQL 8 does not have the old query cache. Do not add obsolete query-cache settings or copy an arbitrary buffer size from another server.
Investigate slow queries and application behaviour before increasing global resource allowances. Record and test each proposed change, using the database service and configuration managed by your hosting platform.
Measure afterwards
Apply approved changes during a suitable maintenance window and verify database and website operation. Gather another representative period of activity before comparing results. Re-running immediately after a restart mostly measures reset counters rather than the change’s benefit.