MySQLTuner is a single Perl script that reads SHOW GLOBAL STATUS and SHOW GLOBAL VARIABLES once and prints heuristics. Download it over HTTPS and give it credentials through a file, not a flag:
curl -fsSLO https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl
printf '[client]\nuser=tuner\npassword=...\n' > ~/.my-tuner.cnf && chmod 600 ~/.my-tuner.cnf
perl mysqltuner.pl --defaults-file=~/.my-tuner.cnf --host 127.0.0.1 --port 3306 --nocolor
Fetching it with wget http://mysqltuner.pl -O mysqltuner.pl still works, but the first hop is unauthenticated plaintext:
$ curl -sSI http://mysqltuner.pl
HTTP/1.1 301 Moved Permanently
Location: https://raw.githubusercontent.com/major/MySQLTuner-perl/refs/heads/master/mysqltuner.pl
Anyone able to answer that first request decides which script you are about to run against your database, with whatever privileges you hand it. Fetch the HTTPS URL directly. Likewise, mysqltuner --user X --password Y puts the password in your shell history and in ps output for every user on the box — MySQLTuner supports --defaults-file precisely so you don’t have to. mysqltuner-optimize-performance-guide.sh confirms the redirect shown above, then runs MySQLTuner against a throwaway MySQL server of its own, with its credentials in a 0600 file, to reproduce the no-uptime, no-traffic report below; it never touches a server you already run.
The caveat the tool prints about itself
Everything MySQLTuner says is derived from counters that reset when mysqld starts. On a server with no uptime and no traffic, the counters are noise — and the script says so, both in its own source and in its output. Run against a MySQL 8.4.10 instance that had been up for one second and had served zero application queries, it still produced this:
-------- Recommendations ------------------------------------------------------
General recommendations:
MySQL was started within the last 24 hours: recommendations may be inaccurate
Enable the slow query log to troubleshoot bad queries
When making adjustments, make tmp_table_size/max_heap_table_size equal
Reduce your SELECT DISTINCT queries which have no LIMIT clause
Primary database bottleneck is Disk I/O. Check storage performance, swap usage, ...
Variables to adjust:
tmp_table_size (> 16M)
max_heap_table_size (> 16M)
Overall Weighted Health Score: 80/100
There were no SELECT DISTINCT queries. There was no disk I/O bottleneck. There was no workload at all. Its own bundled documentation is explicit — perldoc mysqltuner.pl, under IMPORTANT USAGE GUIDELINES: “Allow MySQL server to run for at least 24-48 hours before trusting suggestions”. If a report you have been handed does not state the server’s uptime and query count, it is not evidence of anything. For what the server is doing now rather than what it has accumulated since start-up, performance_schema and the sys schema are already on in 8.4 and need nothing installed.
The same tool on a server with real uptime
Against a MySQL 8.4.10 instance up for 8 days with 2 million queries behind it, the output is worth reading:
ℹ Up for: 8d 7h 6m 58s (2M q [3.374 qps], 51K conn, TX: 3G, RX: 591M)
✔ Slow queries: 0% (0/2M)
✔ Highest usage of available connections: 1% (3/151)
✘ Name resolution is active: a reverse name resolution is made for each new connection
✔ Temporary tables created on disk: 0% (19 on disk / 134K total)
✘ Joins performed without indexes: 12782
✘ table_definition_cache (2000) is less than number of tables (2309)
✘ InnoDB buffer pool / data size: 128.0M / 299.2M
Variables to adjust:
skip-name-resolve=ON
join_buffer_size (> 256.0K, or always use indexes with JOINs)
table_definition_cache (2000) > 2309 or -1 (autosizing if supported)
innodb_buffer_pool_size (>= 299.2M) if possible.
innodb_redo_log_capacity (>= 1.0G)
Three of those five are worth acting on and two are traps.
Act on: innodb_buffer_pool_size smaller than the data set (128 MB of pool for 299 MB of data) is the single highest-value line MySQLTuner produces; table_definition_cache below the table count is a real, cheap fix; and skip-name-resolve removes a reverse DNS lookup from every new connection.
Traps: “Joins performed without indexes: 12782” is Select_full_join, and MySQLTuner’s answer is to raise join_buffer_size. Its own note gives away the better answer — “or always use indexes with JOINs”. A larger join buffer makes a nested-loop scan less catastrophic; an index makes it unnecessary. Find the statements first (performance_schema.events_statements_summary_by_digest ordered by SUM_NO_INDEX_USED, or the slow log with log_queries_not_using_indexes) and index them. Likewise innodb_redo_log_capacity: bigger redo smooths checkpoint spikes but costs crash-recovery time, so it is a decision, not a fix.
Three things it got wrong on 8.4.10
Version 2.9.1 is not fully caught up with MySQL 8.4. Observed in the same run:
- It recommends
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('secure_password'). ThePASSWORD()function was removed in MySQL 8.0; on 8.4.10 that statement is a syntax error:ERROR 1064 (42000) ... near '('x')'. The working form isALTER USER 'root'@'localhost' IDENTIFIED BY '...'. - It printed
Skipped: Performance Schema is disabledwhileSELECT @@performance_schemareturned1on that server — and it had already readperformance_schema.error_logearlier in the same report. - It emitted a Perl warning of its own:
Argument "" isn't numeric in addition (+) at mysqltuner.pl line 1261, and reportedGrowth forecasting: Insufficient uptime (< 24h)against a server it had itself measured at 8 days.
None of that makes the tool useless. It makes it a checklist generator rather than an authority. Use it to find candidates, then confirm each one against SHOW GLOBAL STATUS, performance_schema, and EXPLAIN before you change a running server — and change one thing at a time, because MySQLTuner cannot tell you which of its suggestions helped.
Two settings deserve a warning of their own. innodb_buffer_pool_size at “50-75% of RAM”, the number every tuning guide repeats, assumes a dedicated database host; on a box that also runs your application it will get the server OOM-killed. And max_connections multiplies per-connection buffers — MySQLTuner’s own “Maximum possible memory usage” line, 1.8 G at 151 threads above, is the figure to watch when you raise it.