使用mysqldbcompare 對比數據庫間差異

來源:本站原創 mysql_mariadb 超過1,712 views圍觀 0條評論

 

使用mysqldbcompare 對比數據庫間差異

————-安裝
rpm -ivh https://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-2.1.7-1.el6.x86_64.rpm
rpm -ivh https://dev.mysql.com/get/Downloads/MySQLGUITools/mysql-utilities-1.6.4-1.el6.noarch.rpm
————對比
mysqldbcompare –server1=root:[email protected] \
    –server2=root:[email protected] db1:db2 –changes-for=server1 -a \/
    –difftype=sql

mysqldbcompare –server1=root:[email protected] –server2=root:[email protected] db1:db2 –changes-for=server1 -a –difftype=sql
   
mysqldbcompare –server1=admin:[email protected]:3355 –server2=admin:[email protected]:3356  –changes-for=server1  -a –difftype=sql

使用-a 就不能指定數據庫,是所有庫的對比
mysqldbcompare –server1=admin:[email protected]:3355 –server2=admin:[email protected]:3356  –changes-for=server1  -a –difftype=sql

 
[[email protected] ~]# mysqldbcompare –server1=admin:[email protected]:3355 –server2=admin:[email protected]:3356 –changes-for=server1 budget:budget –difftype=sql
# WARNING: Using a password on the command line interface can be insecure.
# server1 on 172.16.9.83: … connected.
# server2 on 172.16.9.83: … connected.
# Checking databases budget on server1 and budget on server2
#
#                                                   Defn    Row     Data  
# Type      Object Name                             Diff    Count   Check 
# ————————————————————————-
# PROCEDURE head_audit_procedure                    pass    -       -      
# TABLE     base_data_budget                        pass    pass    -      
#           – Compare table checksum                                pass   
# TABLE     budget_body                             pass    pass    -      
#           – Compare table checksum                                FAIL   
 
 
—————參數說明相關文章
  http://www.ttlsa.com/mysql/mysqldbcompare-compare-two-databases/
  https://blog.csdn.net/zxb4221v/article/details/61782128
 
[[email protected] ~]# find / -name mysqldbcompare^C
[[email protected] ~]# mysqldbcompare –server1=admin:[email protected]:3355 –server2=admin:[email protected]:3356 –changes-for=server1 budget:budget
# WARNING: Using a password on the command line interface can be insecure.
# server1 on 172.16.9.83: … connected.
# server2 on 172.16.9.83: … connected.
# Checking databases budget on server1 and budget on server2

下載
https://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-2.1.7-1.el6.x86_64.rpm

[[email protected] ~]# rpm -ivh https://dev.mysql.com/get/Downloads/MySQLGUITools/mysql-utilities-1.6.5-1.el6.noarch.rpm
Retrieving https://dev.mysql.com/get/Downloads/MySQLGUITools/mysql-utilities-1.6.5-1.el6.noarch.rpm
warning: /var/tmp/rpm-tmp.2Ob7hD: 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.5-1.el6.noarch
[[email protected] ~]# yum update mysql-connector-python

yum install https://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-2.1.7-1.el6.x86_64.rpm

 
v[[email protected] ~]# rpm -e  yum install https://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-2.1.7-1.el6.x86_64.rpm^C
[[email protected] ~]# rpm -e mysql-connector-python-1.1.6-1.el6.noarch

 

[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]# rpm -ivh https://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-2.1.7-1.el6.x86_64.rpm
Retrieving https://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-2.1.7-1.el6.x86_64.rpm
warning: /var/tmp/rpm-tmp.CcFjfP: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing…                ########################################### [100%]
   1:mysql-connector-python ########################################### [100%]
[[email protected] ~]#

示例一:檢查server1,server2上的某個表結構是否一致
mysqldiff –server1=user:[email protected]:port –server2=user:[email protected]:port –changes-for=server2  dbname.tablename:dbname.tablename
示例二:檢查server1,server2上的兩個數據庫中的表結構是否一致
mysqldiff –server1=user:[email protected]:port –server2=user:[email protected]:port dbname:dbname –changes-for=server2

3、mysqldbcompare
mysqldiff該工具是官方mysql-utilities工具集的一個腳本,可以用來檢查不同數據庫之間的數據一致性,檢查內容包括數據庫字符集、表結構、數據內容,只要有一個不一樣,則檢查不通過。
示例:
mysqldbcompare –server1=user:[email protected]:3306 –server2=user:[email protected]:3306 –changes-for=server1 dbname:dbname

mysqldbcompare –server1=admin:[email protected]:3355 –server2=admin:[email protected]:3356 –changes-for=server1 budget:budget

文章出自:CCIE那點事 http://www.qdxgqk.live/ 版權所有。本站文章除注明出處外,皆為作者原創文章,可自由引用,但請注明來源。 禁止全文轉載。
本文鏈接:http://www.qdxgqk.live/?p=3740轉載請注明轉自CCIE那點事
如果喜歡:點此訂閱本站
?
?
萌宠夺宝游戏 黑龙江p62彩票 极速塞车免费计划软件 河南快赢481杀号技巧 还能赚钱吗 求前辈了解 一定牛河南快3预测 国外什么店赚钱 浙江快乐彩 jdb财神捕鱼弱点 内蒙古时时彩历史开奖 辽源麻将玩法介绍 福建快三专家 天天乐棋牌游戏下载官网 股票配资公司 3d图谜 哪个网站码字赚钱信誉好的 怎样从vr赚钱