搜尋
首頁資料庫mysql教程MySQL Utilities工具包概述及安裝

MySQL Utilities 是一組基於Python語言編寫的python函式庫的命令列實用工具集,依賴python 2.6。該工具提供了MySQL資料庫維運工程中常用的一些工具,諸如克隆、複製、比較、差異、匯出、匯入、安裝、配置、索引、磁碟檢視等等。有了這個工具包,就好比那些個神醫大夫,不管大病小病,先去搞個化驗,搞個CT,你也可以當華佗。 MySQL Utilities提供了各種平台的軟體包,如果沒有找到對應自己平台的包,可以透過原始碼進行編譯安裝。本文主要描述MySQL Utilities安裝以及各個工作功能初步描述。

一、MySQL Utilities功能及元件

Binary Log Operations(二进制日志操作) 
        mysqlbinlogmove   二进制日志移动
        mysqlbinlogpurge  二进制日志清理
        mysqlbinlogrotate 二进制日志老化工具    
Database Operations(数据库操作)
        mysqldbexport     数据导出
        mysqldbimport     数据导入
        mysqldbcopy       库级别数据库复制
        mysqldiff         数据库对象级别比较工具
        mysqldbcompare    数据库库级别比较工具
General Operations(通用用的操作)     
        mysqldiskusage    磁盘空间查看
        mysqlfrm          恢复故障表.frm文件
        mysqluserclone    用户克隆工具
        mysqluc           Utilities帮助工具 
        mysqlindexcheck   索引检测工具
        mysqlmetagrep     元数据过滤器
        mysqlprocgrep     进程搜索及清理工具
High Availability Operations(高可用)
    mysqlreplicate   主从复制工具
    mysqlrpladmin    主从复制管理工具
    mysqlrplcheck    主从复制检测工具
    mysqlrplms       主从多元复制工具
    mysqlrplshow     主从复制拓扑图工具
    mysqlrplsync     主从复制同步工具
    mysqlfailover    主从failover工具
    mysqlslavetrx    从库事务跳过工具 
Server Operations(服务器操作)
        mysqlserverinfo    服务器信息查看工具
        mysqlserverclone   服务器克隆工具    
Specialized Operations(特殊操作)
        mysqlauditadmin    审计管理工具 
        mysqlauditgrep     审计日志过滤工具

二、安裝需求及下載位址

    需求
            Python 2.6
            MySQL Connector/Python 连接器
    下载地址:
            http://www.php.cn/

三、安裝範例

###本次安装使用1.6.4版本,安装前,需要先安装mysql到python连接器# cat /etc/redhat-release CentOS release 6.7 (Final)
# rpm -Uvh mysql-connector-python-2.1.4-1.el6.x86_64.rpm # rpm -Uvh mysql-utilities-1.6.4-1.el6.noarch.rpm ###如果没有安装连接器,则收到如下错误提示
# rpm -Uvh mysql-utilities-1.6.4-1.el6.noarch.rpm warning: mysql-utilities-1.6.4-1.el6.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
        mysql-connector-python >= 2.0.0 is needed by mysql-utilities-1.6.4-1.el6.noarch###查看安装后生成的文件        
        # rpm -ql mysql-utilities-1.6.4-1.el6|grep "/usr/bin"/usr/bin/mysqlauditadmin
/usr/bin/mysqlauditgrep
/usr/bin/mysqlbinlogmove
/usr/bin/mysqlbinlogpurge
/usr/bin/mysqlbinlogrotate
/usr/bin/mysqldbcompare
/usr/bin/mysqldbcopy
/usr/bin/mysqldbexport
/usr/bin/mysqldbimport
/usr/bin/mysqldiff
/usr/bin/mysqldiskusage
/usr/bin/mysqlfailover
/usr/bin/mysqlfrm
/usr/bin/mysqlgrants
/usr/bin/mysqlindexcheck
/usr/bin/mysqlmetagrep
/usr/bin/mysqlprocgrep
/usr/bin/mysqlreplicate
/usr/bin/mysqlrpladmin
/usr/bin/mysqlrplcheck
/usr/bin/mysqlrplms
/usr/bin/mysqlrplshow
/usr/bin/mysqlrplsync
/usr/bin/mysqlserverclone
/usr/bin/mysqlserverinfo
/usr/bin/mysqlslavetrx
/usr/bin/mysqluc
/usr/bin/mysqluserclone
呼叫mysqluc命令列工具來取得這些工具的幫助資訊### mysqluc提供一個自帶的命令列提示符窗口,

在這個視窗下也可以完成對應的命令操作[root@node1 ~]# mysqlucLaunching console .. .


Welcome to the MySQL Utilities Client (mysqluc) version 1.6.4Copyright (c) 2010, 2016 Oracle and/or its affiliates. All rights reserved.
This is a release of dual licensed MySQL Utilities. For the avoidance ofdoubt, this particular copy of the software is released
under the version 2 of the GNU General Public License.
MySQL Utilities is brought to you by Oracle.
Type 'help' for a list of commands or press TAB twice for list of utilities.
mysqluc> help
Command                 Description                                        
----------------------  ---------------------------------------------------help utilities          
Display list of all utilities supported.           
help <utility>          Display help for a specific utility.               
show errors             Display errors captured during the execution of the
                        utilities.                                         
clear errors            clear captured errors.                             
show last error         Display the last error captured during the         
                        execution of the utilities                         
help | help commands    Show this list.                                    
exit | quit             Exit the console.                                  
set <variable>=<value>  Store a variable for recall in commands.           
show options            Display list of options specified by the user on   
                        launch.                                            
show variables          Display list of variables.                         
<ENTER>                 Press ENTER to execute command.                    
<ESCAPE>                Press ESCAPE to clear the command entry.           
<DOWN>                  Press DOWN to retrieve the previous command.       
<UP>                    Press UP to retrieve the next command in history.  
<TAB>                   Press TAB for type completion of utility, option,  
                        or variable names.                                 
<TAB><TAB>              Press TAB twice for list of matching type          
                        completion (context sensitive).                    
###查看utilities包中所有的命令行工具mysqluc> help utilities 
Utility            Description                                             
-----------------  --------------------------------------------------------mysqlauditadmin    
audit log maintenance utility                           
mysqlauditgrep     audit log search utility                                
mysqlbinlogmove    binary log relocate utility                             
mysqlbinlogpurge   purges unnecessary binary log files                     
mysqlbinlogrotate  rotates the active binary log file                      
mysqldbcompare     compare databases for consistency                       
mysqldbcopy        copy databases from one server to another               
mysqldbexport      export metadata and data from databases                 
mysqldbimport      import metadata and data from files                     
mysqldiff          compare object definitions among objects where the      
                   difference is how db1.obj1 differs from db2.obj2        
mysqldiskusage     show disk usage for databases                           
mysqlfailover      automatic replication health monitoring and failover    
mysqlfrm           show CREATE TABLE from .frm files                       
mysqlgrants        display grants per object                               
mysqlindexcheck    check for duplicate or redundant indexes                
mysqlmetagrep      search metadata                                         
mysqlprocgrep      search process information                              
mysqlreplicate     establish replication with a master                     
mysqlrpladmin      administration utility for MySQL replication            
mysqlrplcheck      check replication                                       
mysqlrplms         establish multi-source replication                      
mysqlrplshow       show slaves attached to a master                        
mysqlrplsync       replication synchronization checker utility             
mysqlserverclone   start another instance of a running server              
mysqlserverinfo    show server information                                 
mysqlslavetrx      skip transactions on slaves                             
mysqluserclone     clone a MySQL user account to one or more new users     
###也可直接在mysqluc提示符下输入 help command 来获取对应命令的帮助信息,如下mysqluc> help mysqlauditadmin 
Usage: mysqlauditadmin --server=user:pass@host:port --show-options # Author : Leshami
# Blog   : http://www.php.cn/mysqlauditadmin - audit log maintenance utility 
Options:
Option                     Description                                     
-------------------------  --------------------------------------------------version                  
show program&#39;s version number and exit          --help                     
display this help message and exit              --license                  
display program&#39;s license and exit              --server=SERVER            
connection information for the server in the    
                           form:                                           
                           <user>[:<password>]@<host>[:<port>][:<socket>]  
                           or <login-path>[:<port>][:<socket>] or <config- 
                           path>[<[group]>].                               
--audit-log-name=LOG_NAME  full path and file name for the audit log file. 
                           Used for stats and copy options.                
--show-options             display the audit log system variables.         
--remote-login=RLOGIN      user name and host to be used for remote login  
                           for copying log files. Format:                  
                           <user>:<host_or_ip> Password will be prompted.  
--file-stats               display the audit log file statistics.          
--copy-to=COPY_LOCATION    the location to copy the audit log file         
                           specified. The path must be locally accessible  
                           for the current user.                           
--value=VALUE              value used to set variables based on the command
                           specified. See --help for list per command.     
                           --ssl-ca=SSL_CA            path to a file that contains a list of trusted  
                           SSL CAs.                                        
--ssl-cert=SSL_CERT        name of the SSL certificate file to use for     
                           establishing a secure connection.               
--ssl-key=SSL_KEY          name of the SSL key file to use for establishing
                           a secure connection.                            
--ssl=SSL                  specifies if the server connection requires use 
                           of SSL. If an encrypted connection cannot be    
                           established, the connection attempt fails. By   
                           default 0 (SSL not required).                   
-v, --verbose              control how much information is displayed. e.g.,
                           -v = verbose, -vv = more verbose, -vvv = debug  
                           Available Commands: copy - copy the audit log to
                           a locally accessible path policy - set the audit                          
                            log policy Values = ALL, NONE, LOGINS, QUERIES, 
                           DEFAULT rotate - perform audit log rotation     
                           rotate_on_size - set the rotate log size limit  
                           for auto rotation Values = 0, 4294967295    
                           2、直接在shell提示符下获取命令帮助###如下示例[root@node1 ~]
                           # mysqlfailover --help|headMySQL Utilities mysqlfailover version 1.6.4 License type: GPLv2
Usage: mysqlfailover --master=root@localhost --discover-slaves-login=root 
                --candidates=root@host123:3306,root@host456:3306 mysqlfailover - automatic replication health monitoring and failover
Options:  --version             show program&#39;s version number and exit
  --help                display this help message and exit
  --license             display program&#39;s license and exit 3、基于Linux man获取命令帮助###如下示例root@node1 ~]
  # man mysqlfailoverMYSQLFAILOVER(1)                MySQL Utilities               MYSQLFAILOVER(1)
NAME
       mysqlfailover - Automatic replication master failover
SYNOPSIS
       mysqlfailover [options]


陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
MySQL:世界上最受歡迎的數據庫的簡介MySQL:世界上最受歡迎的數據庫的簡介Apr 12, 2025 am 12:18 AM

MySQL是一種開源的關係型數據庫管理系統,主要用於快速、可靠地存儲和檢索數據。其工作原理包括客戶端請求、查詢解析、執行查詢和返回結果。使用示例包括創建表、插入和查詢數據,以及高級功能如JOIN操作。常見錯誤涉及SQL語法、數據類型和權限問題,優化建議包括使用索引、優化查詢和分錶分區。

MySQL的重要性:數據存儲和管理MySQL的重要性:數據存儲和管理Apr 12, 2025 am 12:18 AM

MySQL是一個開源的關係型數據庫管理系統,適用於數據存儲、管理、查詢和安全。 1.它支持多種操作系統,廣泛應用於Web應用等領域。 2.通過客戶端-服務器架構和不同存儲引擎,MySQL高效處理數據。 3.基本用法包括創建數據庫和表,插入、查詢和更新數據。 4.高級用法涉及復雜查詢和存儲過程。 5.常見錯誤可通過EXPLAIN語句調試。 6.性能優化包括合理使用索引和優化查詢語句。

為什麼要使用mysql?利益和優勢為什麼要使用mysql?利益和優勢Apr 12, 2025 am 12:17 AM

選擇MySQL的原因是其性能、可靠性、易用性和社區支持。 1.MySQL提供高效的數據存儲和檢索功能,支持多種數據類型和高級查詢操作。 2.採用客戶端-服務器架構和多種存儲引擎,支持事務和查詢優化。 3.易於使用,支持多種操作系統和編程語言。 4.擁有強大的社區支持,提供豐富的資源和解決方案。

描述InnoDB鎖定機制(共享鎖,獨家鎖,意向鎖,記錄鎖,間隙鎖,下一鍵鎖)。描述InnoDB鎖定機制(共享鎖,獨家鎖,意向鎖,記錄鎖,間隙鎖,下一鍵鎖)。Apr 12, 2025 am 12:16 AM

InnoDB的鎖機制包括共享鎖、排他鎖、意向鎖、記錄鎖、間隙鎖和下一個鍵鎖。 1.共享鎖允許事務讀取數據而不阻止其他事務讀取。 2.排他鎖阻止其他事務讀取和修改數據。 3.意向鎖優化鎖效率。 4.記錄鎖鎖定索引記錄。 5.間隙鎖鎖定索引記錄間隙。 6.下一個鍵鎖是記錄鎖和間隙鎖的組合,確保數據一致性。

MySQL查詢性能差的常見原因是什麼?MySQL查詢性能差的常見原因是什麼?Apr 12, 2025 am 12:11 AM

MySQL查询性能不佳的原因主要包括没有使用索引、查询优化器选择错误的执行计划、表设计不合理、数据量过大和锁竞争。1.没有索引导致查询缓慢,添加索引后可显著提升性能。2.使用EXPLAIN命令可以分析查询计划,找出优化器错误。3.重构表结构和优化JOIN条件可改善表设计问题。4.数据量大时,采用分区和分表策略。5.高并发环境下,优化事务和锁策略可减少锁竞争。

您什麼時候應該使用複合索引與多個單列索引?您什麼時候應該使用複合索引與多個單列索引?Apr 11, 2025 am 12:06 AM

在數據庫優化中,應根據查詢需求選擇索引策略:1.當查詢涉及多個列且條件順序固定時,使用複合索引;2.當查詢涉及多個列但條件順序不固定時,使用多個單列索引。複合索引適用於優化多列查詢,單列索引則適合單列查詢。

如何識別和優化MySQL中的慢速查詢? (慢查詢日誌,performance_schema)如何識別和優化MySQL中的慢速查詢? (慢查詢日誌,performance_schema)Apr 10, 2025 am 09:36 AM

要優化MySQL慢查詢,需使用slowquerylog和performance_schema:1.啟用slowquerylog並設置閾值,記錄慢查詢;2.利用performance_schema分析查詢執行細節,找出性能瓶頸並優化。

MySQL和SQL:開發人員的基本技能MySQL和SQL:開發人員的基本技能Apr 10, 2025 am 09:30 AM

MySQL和SQL是開發者必備技能。 1.MySQL是開源的關係型數據庫管理系統,SQL是用於管理和操作數據庫的標準語言。 2.MySQL通過高效的數據存儲和檢索功能支持多種存儲引擎,SQL通過簡單語句完成複雜數據操作。 3.使用示例包括基本查詢和高級查詢,如按條件過濾和排序。 4.常見錯誤包括語法錯誤和性能問題,可通過檢查SQL語句和使用EXPLAIN命令優化。 5.性能優化技巧包括使用索引、避免全表掃描、優化JOIN操作和提升代碼可讀性。

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳圖形設置
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您聽不到任何人,如何修復音頻
3 週前By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解鎖Myrise中的所有內容
4 週前By尊渡假赌尊渡假赌尊渡假赌

熱工具

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

DVWA

DVWA

Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中

Atom編輯器mac版下載

Atom編輯器mac版下載

最受歡迎的的開源編輯器

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。