| 指令 | 用途 | 範例 |
|---|---|---|
shutdown | 關閉 Server | mysqladmin -h10.101.0.1 -uroot -p123456 shutdown |
ping | 檢查存活 | mysqladmin -h10.101.0.1 ping |
processlist | 顯示執行緒 | mysqladmin -h10.101.0.1 -uroot -p processlist |
status | 簡短狀態 | mysqladmin -h10.101.0.1 status |
variables | 顯示系統變數 | mysqladmin -h10.101.0.1 variables |
version | 版本資訊 | mysqladmin -h10.101.0.1 version |
flush-privileges | 重載權限 | mysqladmin -h10.101.0.1 flush-privileges |
kill id,id... | 殺掉執行緒 | mysqladmin -h10.101.0.1 kill 123,456 |
-h, --host=name 遠程主機
-u, --user=name 登入用戶
-p, --password[=name] 密碼 (不帶值會互動輸入)
-P, --port=# Port (預設 3306)
--protocol=tcp|socket|pipe|memory
--connect_timeout=# 連線逾時
--shutdown_timeout=# 關機等待逾時
mysqladmin Ver 8.42 Distrib 5.5.2-m2
Usage: mysqladmin [OPTIONS] command command...
-c, --count=# 重複次數 (搭配 -i)
--debug-check 退出時檢查記憶體
--debug-info 退出時印除錯資訊
-f, --force 強制執行 (不確認 drop database)
-C, --compress 啟用壓縮協定
--character-sets-dir 字符集目錄
--default-character-set
-?, --help 顯示幫助
-b, --no-beep 錯誤不嗶聲
-W, --pipe Windows Named Pipe
-r, --relative 顯示差值 (搭配 -i extended-status)
-O, --set-variable 設定變數 (已棄用,改用 --var=value)
-s, --silent 連不上靜默退出
-S, --socket=name Unix Socket 檔案
-i, --sleep=# 間隔秒數重複執行
--ssl 啟用 SSL
--ssl-ca/capath/cert/cipher/key
--ssl-verify-server-cert
-v, --verbose 詳細輸出
-V, --version 版本資訊
-E, --vertical 垂直顯示
-w, --wait[=#] 連線失敗重試
mysqladmin -h192.168.1.100 -uroot -p'StrongPass' shutdown
mysqladmin -h192.168.1.100 -uroot -p -i 5 processlist
mysqladmin -h192.168.1.100 -uroot -p extended-status | grep -i innodb
bind-address=0.0.0.0 且帳號有 SHUTDOWN/PROCESS 權限shutdown 會等待進行中事務完成,若需強制可先 kill 長事務再 shutdownmysqladmin 是輕量級遠程管理利器,掌握 shutdown/ping/processlist/status/variables/kill 核心指令,配合 -h/-u/-p/-i 參數,即可完成 90% 運維操作無需登入 Shell。