安装Mysql Utilities
mysql utilities 使用python开发,首先需要安装MySQL Connector/Python General Availability (GA) release。
tar zxvf mysql-connector-python-2.1.3.tar.gz
cd mysql-connector-python-2.1.3
python setup.py --help
python ./setup.py build
sudo python ./setup.py install
2.python版本需要时2.6或者2.7.接下来安装utilities。
tar zxvf mysql-utilities-1.6.3.tar.gz
cd mysql-utilities-1.6.3
python ./setup.py build
sudo python ./setup.py install
命令行
5.1 mysqlauditadmin — Allows users to perform maintenance action on the audit log
5.2 mysqlauditgrep — Allows users to search the current or an archived audit log
5.3 mysqlbinlogmove — Binary log relocate utility
5.4 mysqlbinlogpurge — Binary log purge utility
5.5 mysqlbinlogrotate — Binary log rotate utility
5.6 mysqldbcompare — Compare Two Databases and Identify Differences
5.7 mysqldbcopy — Copy Database Objects Between Servers
5.8 mysqldbexport — Export Object Definitions or Data from a Database
5.9 mysqldbimport — Import Object Definitions or Data into a Database
5.10 mysqldiff — Identify Differences Among Database Objects
5.11 mysqldiskusage — Show Database Disk Usage
5.12 mysqlfailover — Automatic replication health monitoring and failover
5.13 mysqlfrm — File reader for .frm files.
5.14 mysqlgrants — Display grants by object
5.15 mysqlindexcheck — Identify Potentially Redundant Table Indexes
5.16 mysqlmetagrep — Search Database Object Definitions
5.17 mysqlprocgrep — Search Server Process Lists
5.18 mysqlreplicate — Set Up and Start Replication Between Two Servers
5.19 mysqlrplms — Set Up and Start Replication Among a Slave and Multiple Masters
5.20 mysqlrpladmin — Administration utility for MySQL replication
5.21 mysqlrplcheck — Check Replication Prerequisites
5.22 mysqlrplshow — Show Slaves for Master Server
5.23 mysqlrplsync — Replication synchronization checker
5.24 mysqlserverclone — Clone Existing Server to Create New Server
5.25 mysqlserverinfo — Display Common Diagnostic Information from a Server
5.26 mysqlslavetrx — Slave transaction skip utility
5.27 mysqluc — Command line client for running MySQL Utilities
5.28 mysqluserclone — Clone Existing User to Create New User
连接数据库
连接数据库有三种方式:
Use login-paths from your .mylogin.cnf file (encrypted, not visible). Example : [:][:]
Use a configuration file (unencrypted, not visible) Note: available in release-1.5.0. Example : [:]
Specify the data on the command-line (unencrypted, visible). Example : [:]@[:][:]
其中第二种方式,配置文件内容如下:
[server_test121]
port=3306
user=root
password=123456
host=127.0.0.1
通过命令行查看数据库信息:
mysqlserverinfo --server=./server.cnf[server_test121] --format=vertical
mysqldiff
mysqldiff是用来比较数据库Object之间的差异,如果比较表数据,可以使用mysqlcompare.
mysqldiff --server1=./server.cnf[server_test121] --difftype=sql db1.app_config:db2.app_config
通过--server1指定left数据库,--server2指定right数据库,缺省是使用server1。differtype指定输出格式。