MySQL-Utilities:mysqldiff
园子看到使用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的更多相关文章
- MySQL utilities介绍&出现 No module named utilities
目录 安装 mysqlreplicate mysqlrplcheck mysqlrplshow mysqlrpladmin mysqlfailover mysqldbcompare 详细介绍 mysq ...
- MySQL Utilities管理工具
前提: 1.安装MySQL Utilities工具 2.复制my_print_defaults命令至/usr/bin下或写入环境变量. 卸载方式: python ./setup.py clean -- ...
- (5.6)mysql高可用系列——MySQL Utilities 管理工具
关键词:mysql工具集,mysql管理工具,mysql utilities [1]安装mysql utilities cd /download wget https://cdn.mysql.com/ ...
- MySQL Utilities工具教程
一.MySQL Utilities介绍 MySQL Utilities 提供一组命令行工具用于维护和管理 MySQL 服务器,包括: 管理工具 (克隆.复制.比较.差异.导出.导入)复制工具 (安装. ...
- MySQL管理工具MySQL Utilities — 介绍与安装(1)
MySQL Utilities介绍 MySQL Utilities 提供一组命令行工具用于维护和管理 MySQL 服务器,包括: 管理工具 (克隆.复制.比较.差异.导出.导入) 复制工具 (安装.配 ...
- 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 ...
- MySQL错误:The user specified as a definer (XXX@XXX) does not exist
今天由于更换服务器,重新再本地备份了数据库,试运行程序报错,如下: MySQL错误:The user specified as a definer (XXX@XXX) does not exist 意 ...
- MySQL内核:InnoDB存储引擎 卷1
MySQL内核:InnoDB存储引擎卷1(MySQL领域Oracle ACE专家力作,众多MySQL Oracle ACE力捧,深入MySQL数据库内核源码分析,InnoDB内核开发与优化必备宝典) ...
- MySQL查询优化:查询慢原因和解决技巧
在开发的朋友特别是和mysql有接触的朋友会碰到有时mysql查询很慢,当然我指的是大数据量百万千万级了,不是几十条了,下面我们来看看解决查询慢的办法. MySQL查询优化:查询慢原因和解决方法 会经 ...
随机推荐
- git -- 项目开发最常用操作记录
官方Git - Book https://git-scm.com/book/zh/v2 ------------------------------git配置以及公钥生成--------------- ...
- 2019-8-30-PowerShell-通过-WMI-获取系统安装的驱动
title author date CreateTime categories PowerShell 通过 WMI 获取系统安装的驱动 lindexi 2019-08-30 08:58:39 +080 ...
- 思维构造,建图——cf1159E
很好的题 /* nexti:pi右边第一个比pi大的数的下标 把每个[i,a[i]]都看成一段区间,区间只能在端点处交叉,以此来判断是否有解 特别的,如果a[i]=-1,那么把a[i]=i+1,不对其 ...
- 微信小程序chooseImage(从本地相册选择图片或使用相机拍照)
一.使用API wx.chooseImage(OBJECT) var util = require('../../utils/util.js') Page({ data:{ src:"../ ...
- Workman-Thrift疑问解析
Workman是纯纯的PHP实现的一套网络通信框架,Workman-Thrift则是以Workman为基础,为Thrift RPC实现网络通信.经过学习与测试,现把自己的疑问与验证记录下来: 问题一: ...
- matlab调用keras深度学习模型(环境搭建)
matlab没有直接调用tensorflow模型的接口,但是有调用keras模型的接口,而keras又是tensorflow的高级封装版本,所以就研究一下这个……可以将model-based方法和le ...
- Synchronized理解及用法
加锁: 1.同步实例方法,锁是当前实例对象 2.同步类方法,锁的是当前类对象 3.同步代码块,锁是括号里面的对象 原理: JVM内置锁通过synchronized使用,通过内部对象Monitor(监视 ...
- 01-python 学习第一天
今天是学习python语言的第一天,通过中国大学MOOC网的相关课程和其他在线教程,对python 语言有了初步的认识.今天我记住了<人生苦短,Python是岸>这句话.如果有人学习,建议 ...
- BigNum模板
#include<iostream> #include<cstring> #include<iomanip> #include<algorithm> u ...
- 启用或禁用对 Exchange Server 中的邮箱的 POP3 或 IMAP4 访问
https://docs.microsoft.com/zh-cn/Exchange/clients/pop3-and-imap4/configure-mailbox-access?view=exchs ...