mysql調優工具
- 2019 年 10 月 5 日
- 筆記
下載地址:
https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl
直接使用
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl
下載即可。
chmod +x mysqltuner.pl
./mysqltuner.pl 然後輸入用戶名和密碼即可。
下圖是我一台線上伺服器的檢測結果。

瀏覽輸出的結果,特別是末尾的 Recommendations ,裡面一般會提到您需要在 my.cnf 修改的內容。修改 my.cnf 後記得重啟 MySQL 。重啟後再運行 MySQLTuner 檢查。
另外需要注意的是 MySQL 需要啟動 24 小時候再運行 MySQLTuner ,不然有些內容會不準。
另外,./mysqltuner.pl --help 能顯示支援哪些參數。【從下面的參數可以發現這個工具還支援遠程主機的體檢】
Connection and Authentication
--host <hostname> Connect to a remote host to perform tests (default: localhost)
--socket <socket> Use a different socket for a local connection
--port <port> Port to use for connection (default: 3306)
--user <username> Username to use for authentication
--pass <password> Password to use for authentication
--defaults-file <path> Path to a custom .my.cnf
--mysqladmin <path> Path to a custom mysqladmin executable
--mysqlcmd <path> Path to a custom mysql executable
--noask Don't ask password if needed
Performance and Reporting Options
--skipsize Don't enumerate tables and their types/sizes (default: on)
(Recommended for servers with many tables)
--skippassword Don't perform checks on user passwords(default: off)
--checkversion Check for updates to MySQLTuner (default: don't check)
--updateversion Check for updates to MySQLTuner and update when newer version is available (default: don't check)
--forcemem <size> Amount of RAM installed in megabytes
--forceswap <size> Amount of swap memory configured in megabytes
--passwordfile <path>Path to a password file list(one password by line)
Output Options:
--silent Don't output anything on screen
--nogood Remove OK responses
--nobad Remove negative/suggestion responses
--noinfo Remove informational responses
--debug Print debug information
--dbstat Print database information
--idxstat Print index information
--sysstat Print system information
--pfstat Print Performance schema information
--bannedports Ports banned separated by comma(,)
--maxportallowed Number of ports opened allowed on this hosts
--cvefile CVE File for vulnerability checks
--nocolor Don't print output in color
--json Print result as JSON string
--prettyjson Print result as human readable JSON
--buffers Print global and per-thread buffer values
--outputfile <path> Path to a output txt file
--reportfile <path> Path to a report txt file
--template <path> Path to a template file
--verbose Prints out all options (default: no verbose)
例如我有1台伺服器,上面跑的是多實例的mysql上面,體檢的話,需要使用
./mysqltuner.pl --socket /data/multi_instance/3306/mysql.sock