mysql-utilities 管理工具集的使用
更詳細的參數 ,參照官方文檔: https://dev.mysql.com/doc/mysql-utilities/
直接去MySQL官網下載rpm包安裝即可。如果安裝過程中提示mysql-connector-python版本過低,則到mysql官網去下載個最新的包裝上即可。
社區版用不到或者不常用的功能,筆記這裏就不列出來了。
mysqldbcopy 克隆整個庫
例:mysqldbcopy --source=root:'123456'@localhost:3306:/tmp/mysql.sock --destination=root:'123456'@localhost:3306:/tmp/mysql.sock db:db_clone
mysqldiskusage 統計表空間、各種日誌文件占用的體積
例:mysqldiskusage --server=root:'123456'@localhost:3306:/tmp/mysql.sock --all -v
mysqlfrm 在故障的時候根據frm提取某個表結構 (不包括外鍵約束、自增長序列編號)
例: mysqlfrm --basedir=/usr/local/mysql /data/hellodb/classes.frm --port=3310 --user=root # 註意這個端口是隨便起的
mysqlindexcheck 找出某個庫下的冗余索引
例:mysqlindexcheck --server=root:'123456'@localhost:3306:/tmp/mysql.sock grafana -f vertical -r -d --stats
mysqlprocgrep 找出符合某些條件的用戶連接
參數:
-G, --basic-regexp, --regexp
use 'REGEXP' operator to match pattern. Default is to
use 'LIKE'.
-Q, --print-sql, --sql
print the statement instead of sending it to the
server. If a kill option is submitted, a procedure
will be generated containing the code for executing
the kill.
--sql-body only print the body of the procedure.
--kill-connection kill all matching connections.
--kill-query kill query for all matching processes.
--print print all matching processes.
-f FORMAT, --format=FORMAT
display the output in either grid (default), tab, csv,
or vertical format
-v, --verbose control how much information is displayed. e.g., -v =
verbose, -vv = more verbose, -vvv = debug
--match-id=PATTERN match the 'ID' column of the PROCESSLIST table.
--match-user=PATTERN match the 'USER' column of the PROCESSLIST table.
--match-host=PATTERN match the 'HOST' column of the PROCESSLIST table.
--match-db=PATTERN match the 'DB' column of the PROCESSLIST table.
--match-command=PATTERN
match the 'COMMAND' column of the PROCESSLIST table.
--match-info=PATTERN match the 'INFO' column of the PROCESSLIST table.
--match-state=PATTERN
match the 'STATE' column of the PROCESSLIST table.
--age=AGE show only processes that have been in the current
state more than a given time.
例:# kill掉sleep狀態,且處於sleep超過90秒的用戶連接:
mysqlprocgrep --server=root:'123456'@localhost:3306:/tmp/mysql.sock -f vertical --match-command='Sleep' --age=90s --kill-connection
mysqlrpladmin
關於這個工具,可以參考蘭春大神的博文 https://yq.aliyun.com/articles/59234#
mysqlserverinfo 列出數據庫的明細情況(-d 顯示各個default值, --format=vertical 列式顯示)
例:mysqlserverinfo --server=root:'123456'@localhost:3306:/tmp/mysql.sock -d --format=vertical
mysqlbinlogpurge 清理過期的binlog文件
例:mysqlbinlogpurge --server=root:'123456'@localhost:3306:/tmp/mysql.sock
mysql-utilities 管理工具集的使用