2 Star 7 Fork 2

vimda2/mysqlSync

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

注意

同步两张表之间的表结构。 模仿navict中同步数据库功能。 适合于开发和测试环境之间同步表结构使用 ,修改表结构会导致数据丢失。 生产环境慎用,单纯添加表、字段、索引不受影响。

删除字段

SET FOREIGN_KEY_CHECKS = 0; 
alter table `portal_name` DROP COLUMN `name`; 
alter table `portal_name` DROP COLUMN `age`; 
SET FOREIGN_KEY_CHECKS = 1; 

参考并改自:https://gitee.com/alchemystar/Lancer

mysqlSync

同步两个DB之间的schema,配置如下:
sourceHost=127.0.0.1:3306
sourceUser=root
sourcePass=123123123
sourceSchema=temp_db
sourceCharset=utf8

targetHost=127.0.0.1:3306
targetUser=root
targetPass=123123123
targetSchema=temp_test
targetCharset=utf8

autoExecute=YES //此处表明自动同步

原理: 通过捞取information_schema来比较source_schema和target_schema(可在不同实例)的表结构是否一致,
如果target_schema没有则这张表则创建,
如果target_schema表里面没有这个字段则alter add(保证顺序),
如果表里面有这个字段、但属性不一样则alter change,
另外还同步索引的元数据.

MIT License Copyright (c) 2019 eblly Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

mysql数据库表结构同步 展开 收起
README
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/vimda2/mysqlSync.git
git@gitee.com:vimda2/mysqlSync.git
vimda2
mysqlSync
mysqlSync
master

搜索帮助