mysqldiff对比主从表结构是否一致

WBOY
풀어 주다: 2016-06-07 16:08:19
원래의
1009명이 탐색했습니다.

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

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:123456@192.168.79.10 --server2=admin:123456@192.168.79.11  --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:123456@192.168.79.10 --server2=admin:123456@192.168.79.11  --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.



本文出自 “贺春旸的技术专栏” 博客,,请务必保留此出处

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!