亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

mysqldiff對比主從表結構是否一致

標簽:
MySQL


mysqldiff该工具是官方mysql-utilities工具集的一个脚本,可以实现主从服务器表结构是否一致。数据校验需要使用Percona的pt-table-checksum工具。

安装:

# tar zxvf mysql-utilities-1.5.4.tar.gz

# cd mysql-utilities-1.5.4

# python setup.py install

使用方法:

mysqldiff --server1=admin:[email protected] --server2=admin:[email protected] 

--difftype=differ test:test

# WARNING: Using a password on the command line interface can be insecure.

# server1 on 192.168.79.10: ... connected.

# server2 on 192.168.79.11: ... connected.

# Comparing `test` to `test`                                       [PASS]

# Comparing `test`.`t1` to `test`.`t1`                             [FAIL]

# Object definitions differ. (--changes-for=server1)

#

  CREATE TABLE `t1` (

    `id` int(11) DEFAULT NULL,

-   `name` char(4) DEFAULT NULL

?               ^

+   `name` char(16) DEFAULT NULL

?               ^^

  ) ENGINE=InnoDB DEFAULT CHARSET=utf8

Compare failed. One or more differences found.

很直观的找出不一样的地方。

如果你想打印出修改表结构的语句,如下:

# mysqldiff --server1=admin:[email protected] --server2=admin:[email protected] 

--difftype=sql test:test

# WARNING: Using a password on the command line interface can be insecure.

# server1 on 192.168.79.10: ... connected.

# server2 on 192.168.79.11: ... connected.

# Comparing `test` to `test`                                       [PASS]

# Comparing `test`.`t1` to `test`.`t1`                             [FAIL]

# Transformation for --changes-for=server1:

#

ALTER TABLE `test`.`t1` 

  CHANGE COLUMN name name char(16) NULL;

Compare failed. One or more differences found.

附件:http://down.51cto.com/data/2365598

©著作权归作者所有:来自51CTO博客作者hcymysql的原创作品,如需转载,请注明出处,否则将追究法律责任

mysql主从表mysqldiffMySQL管理


點擊查看更多內容
TA 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學習,寫下你的評論
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消