园子看到使用MySQL对比数据库表结构,参考测试发现

mysql> use test;
create table test1
(id int not null primary key,
a varchar(10) not null,
b varchar(10),
c varchar(10) comment 'c',
d int
)
ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='test1';
create table test2
(id int not null ,
a varchar(10),
b varchar(5),
c varchar(10),
D int
)
ENGINE=myisam DEFAULT CHARSET=utf8 COMMENT='test2';
[root@localhost uest]# mysqldiff --server1=root:mysql5635@localhost:3306 --server2=root:mysql5635@localhost:3306 --changes-for=server2 --show-reverse --difftype=sql test.test1:test.test2
bash: mysqldiff: command not found
[root@localhost uest]#

搜索才知道mysqldiff工具是官方MySQL-Utilities工具集的一个脚本。mysqldiff用来比较对象的定义是否相同并显示不同的地方,mysqldiff 是通过对象名称来进行比较的。
系统环境紧接上一篇,因此需下载相应的rpm包

[root@localhost tools]# wget https://cdn.mysql.com//Downloads/MySQLGUITools/mysql-utilities-1.6.5-1.el6.noarch.rpm
[root@localhost tools]# rpm -ivh mysql-utilities-1.6.-.el6.noarch.rpm
warning: mysql-utilities-1.6.-.el6.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
mysql-connector-python >= 2.0. is needed by mysql-utilities-1.6.-.el6.noarch
[root@localhost tools]#

需要依赖文件

[root@localhost tools]# wget https://cdn.mysql.com//Downloads/Connector-Python/mysql-connector-python-2.1.5-1.el6.i686.rpm
[root@localhost tools]# rpm -ivh mysql-connector-python-2.1.-.el6.i686.rpm
warning: mysql-connector-python-2.1.-.el6.i686.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [%]
:mysql-connector-python ########################################### [%]
[root@localhost tools]# rpm -ivh mysql-utilities-1.6.-.el6.noarch.rpm
warning: mysql-utilities-1.6.-.el6.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [%]
:mysql-utilities ########################################### [%]
[root@localhost tools]#

然后就可以执行mysqldiff命令了

[root@localhost tools]# mysqldiff --server1=root:mysql5635@localhost:3306 --server2=root:mysql5635@localhost:3306 --changes-for=server2 --skip-table-options --show-reverse --difftype=sql test.test1:test.test2
# WARNING: Using a password on the command line interface can be insecure.
# server1 on localhost: ... connected.
# server2 on localhost: ... connected.
# Comparing test.test1 to test.test2 [FAIL]
# Transformation for --changes-for=server2:
# ALTER TABLE `test`.`test2`
DROP COLUMN D,
ADD PRIMARY KEY(`id`),
CHANGE COLUMN b b varchar() NULL,
ADD COLUMN d int() NULL AFTER c,
CHANGE COLUMN a a varchar() NOT NULL,
CHANGE COLUMN c c varchar() NULL COMMENT 'c'; #
# Transformation for reverse changes (--changes-for=server1):
#
# ALTER TABLE `test`.`test1`
# DROP PRIMARY KEY,
# DROP COLUMN d,
# CHANGE COLUMN b b varchar() NULL,
# ADD COLUMN D int() NULL AFTER c,
# CHANGE COLUMN a a varchar() NULL,
# CHANGE COLUMN c c varchar() NULL;
# # Compare failed. One or more differences found.
[root@localhost tools]#

MySQL Utilities 提供一组命令行工具用于维护和管理 MySQL 服务器,可参考官方手册,或者查阅MySQL Utilities教程

MySQL-Utilities:mysqldiff的更多相关文章

  1. MySQL utilities介绍&出现 No module named utilities

    目录 安装 mysqlreplicate mysqlrplcheck mysqlrplshow mysqlrpladmin mysqlfailover mysqldbcompare 详细介绍 mysq ...

  2. MySQL Utilities管理工具

    前提: 1.安装MySQL Utilities工具 2.复制my_print_defaults命令至/usr/bin下或写入环境变量. 卸载方式: python ./setup.py clean -- ...

  3. (5.6)mysql高可用系列——MySQL Utilities 管理工具

    关键词:mysql工具集,mysql管理工具,mysql utilities [1]安装mysql utilities cd /download wget https://cdn.mysql.com/ ...

  4. MySQL Utilities工具教程

    一.MySQL Utilities介绍 MySQL Utilities 提供一组命令行工具用于维护和管理 MySQL 服务器,包括: 管理工具 (克隆.复制.比较.差异.导出.导入)复制工具 (安装. ...

  5. MySQL管理工具MySQL Utilities — 介绍与安装(1)

    MySQL Utilities介绍 MySQL Utilities 提供一组命令行工具用于维护和管理 MySQL 服务器,包括: 管理工具 (克隆.复制.比较.差异.导出.导入) 复制工具 (安装.配 ...

  6. Windows mysql提示:1045 access denied for user 'root'@'localhost' using password yes

    Windows mysql提示:1045 access denied for user 'root'@'localhost' using password yes http://blog.csdn.n ...

  7. MySQL错误:The user specified as a definer (XXX@XXX) does not exist

    今天由于更换服务器,重新再本地备份了数据库,试运行程序报错,如下: MySQL错误:The user specified as a definer (XXX@XXX) does not exist 意 ...

  8. MySQL内核:InnoDB存储引擎 卷1

    MySQL内核:InnoDB存储引擎卷1(MySQL领域Oracle ACE专家力作,众多MySQL Oracle ACE力捧,深入MySQL数据库内核源码分析,InnoDB内核开发与优化必备宝典) ...

  9. MySQL查询优化:查询慢原因和解决技巧

    在开发的朋友特别是和mysql有接触的朋友会碰到有时mysql查询很慢,当然我指的是大数据量百万千万级了,不是几十条了,下面我们来看看解决查询慢的办法. MySQL查询优化:查询慢原因和解决方法 会经 ...

随机推荐

  1. 解决方案 -SQL脚本建表产生ORA-00942错误

    一.问题简介 1.开发环境 操作系统:win10 数 据 库:Oracle11g 数据库连接工具:Navicat  Premium 2.问题简述 在使用SQL Development.Navicat  ...

  2. Python collection模块与深浅拷贝

    collection模块是对Python的通用内置容器:字典.列表.元组和集合的扩展,它包含一些专业的容器数据类型: Counter(计数器):dict子类,用于计算可哈希性对象的个数. Ordere ...

  3. HDU-1423-Greatest Common Increasing Subsequence-最长公共上升子序列【模版】

    This is a problem from ZOJ 2432.To make it easyer,you just need output the length of the subsequence ...

  4. Day 6:集合(set)

    集合(set)定义:由不同元素组成的集合,集合中是一组无序排列的可hash值,可以作为字典的key特性:集合里面数据类型是不可变的1.可变的数据类型:列表,字典2.不可变的数据类型:数字.元组.字符串 ...

  5. springboot跨域访问

    写一个WebMvc配置类重写addCorsMappings即可 @Configuration public class MyMvcConfig implements WebMvcConfigurer ...

  6. js判断客服端

    ua: function () {                    return navigator.userAgent.toLowerCase()                },      ...

  7. [JZOJ4673] 【NOIP2016提高A组模拟7.20】LCS again

    题目 描述 题目大意 给你一个字符串和字符的取值范围,问和这个字符串的最长公共子串的长度为N−1N-1N−1的串的个数. 思考历程 一看就知道这是一个神仙题. 思考了一会儿,觉得AC是没有希望的了. ...

  8. 代码内存泄露检测工具(linux gcc + valrind)

    参考博客: https://www.cnblogs.com/wangkangluo1/archive/2011/07/20/2111248.html linux命令如下:valgrind --tool ...

  9. Apache Flink 进阶入门(二):Time 深度解析

    前言 Flink 的 API 大体上可以划分为三个层次:处于最底层的 ProcessFunction.中间一层的 DataStream API 和最上层的 SQL/Table API,这三层中的每一层 ...

  10. 异或前缀和,组合数学——cf1054D

    /* 每个异或前缀和sum[i]只有两个值 区间异或和不为0,即两个不相等的前缀和 sum[i]的两个前缀和只要标记一个就可以了,为了去重只用map保存最小的那个来计数 最后统计相同的前缀和时,为了使 ...