在MySQL中同步两个数据库架构 [英] Synchronize two databases schema in MySQL
问题描述
我一直在寻找可同步两个MySQL数据库模式的可移植脚本或命令行程序.我不是在寻找基于GUI的解决方案,因为该解决方案无法自动化,也无法与buid/deployment工具一起运行.
I was looking for a portable script or command line program that can synchronize two MySQL databases schema. I am not looking for a GUI based solution because that can't be automated or run with the buid/deployment tool.
基本上,它应该做的是扫描database1和database2.检查架构差异(表和索引),并提出一堆SQL语句在一个语句上运行,以便获得与另一个相似的结构,从而尽可能地减少数据损坏.
Basically what it should do is scan database1 and database2. Check the schema difference (tables and indexes) and propose a bunch of SQL statements to run on one so that it gets the similiar structure of the other minimizing data damage as much as possible.
如果有人可以指出在其中实施了这种解决方案的PHP,Python或Ruby软件包,我可以尝试从那里复制代码.
If someone can indicate a PHP, Python or Ruby package where this type of solution is implemented, I can try to copy the code from there.
许多MySQL GUI工具可能可以做到这一点,但我正在寻找一种可编写脚本的解决方案.
A lot of MySQL GUI tools probably can do this, but I am looking for a scriptable solution.
很抱歉,我不清楚:我正在寻找的是表结构中的同步,同时尽可能保持数据完整.不是数据复制.
Sorry for not being more clear: What I am looking for is synchronization in table structure while keeping data intact as far as possible. Not data replication.
更多信息:
为什么复制不起作用.
- 安装基础遍布全国.
- 我们希望安装程序根据最新版本中的更改对数据库执行动态修复,而不考虑最终用户可能使用的是哪个旧版本.
- 更改主要类似于在表中添加新列,创建新索引或删除索引,添加表或删除系统内部使用的表(我们不删除用户数据表).
如果它是GUI:否,无法使用.我们不想将20MB应用程序仅与DB diff捆绑在一起.特别是当原始安装程序小于1 MB时.
If it's a GUI: No it can't be used. We don't want to bunddle a 20MB app with our installer just for DB diff. Specially when the original installer is less than 1 MB.
推荐答案
您是否考虑过使用 MySQL复制吗?
这篇关于在MySQL中同步两个数据库架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!