当前位置: 首页 > 工具软件 > mysqldiff > 使用案例 >

59.MySQL-Utilities工具包之-mysqldiff

胡承载
2023-12-01

检查对象差异
1.mysqldiff

比较:当前数据库实例中:test数据库和test2数据库里面有哪些不一样的表。
[root@mysql1 ~]# mysqldiff --server1=root:rootroot@192.168.1.51:3306:/mysql/mysql3306.sock --server2=root:rootroot@192.168.1.51:3306:/mysql/mysql3306.sock test:test2 
# WARNING: Using a password on the command line interface can be insecure.
# server1 on 192.168.1.51: ... connected.
# server2 on 192.168.1.58: ... connected.
# WARNING: Objects in server1.test but not in server2.test2:
#        TABLE: test2
# Compare failed. One or more differences found.

2.节点1的:test.test1 表是否和节点1的test2.test1 相同。
[root@mysql1 ~]# mysqldiff --server1=root:rootroot@192.168.1.51:3306:/mysql/mysql3306.sock --server2=root:rootroot@192.168.1.51:3306:/mysql/mysql3306.sock test.test1:test2.test1  
# WARNING: Using a password on the command line interface can be insecure.
# server1 on 192.168.1.51: ... connected.
# server2 on 192.168.1.58: ... connected.
# Comparing test.test1 to test2.test1                              [PASS]
# Success. All objects are the same.

3.
[root@mysql1 ~]# mysqldiff --server1=root:rootroot@192.168.1.51:3306:/mysql/mysql3306.sock --server2=root:rootroot@192.168.1.51:3306:/mysql/mysql3306.sock test:test2
# WARNING: Using a password on the command line interface can be insecure.
# server1 on 192.168.1.51: ... connected.
# server2 on 192.168.1.51: ... connected.
# WARNING: Objects in server1.test but not in server1.test2:
#        TABLE: test3
#        TABLE: test2
# Compare failed. One or more differences found

4.总结
该工具只能比较当前节点上两个数据库的表个数的差异,该工具不实用,无法描述表或数据的具体差异。或者两个远程数据库的差异。

 类似资料: