hidu / mysql-schema-sync Goto Github PK
View Code? Open in Web Editor NEWmysql表结构自动同步工具(目前只支持字段、索引的同步,分区等高级功能暂不支持)
License: MIT License
mysql表结构自动同步工具(目前只支持字段、索引的同步,分区等高级功能暂不支持)
License: MIT License
如:add column Name
varchar(10) DEFAULT ‘’ NULL AFTER AGE
能否去掉建表语句中的 AUTO_INCREMENT= XXX
希望在目的端建新表的时候, AUTO_INCREMENT= 1 或者把 AUTO_INCREMENT= XXX 去掉
现在有了过滤alter的功能,其实有些表是不需要对比的,在对比前就应该过滤掉,这样可以减少点时间消耗。希望能增加一个过滤表的功能。
我是java开发,不会go,想用这个工具,但是想知道下原理,一般是通过binlog同步的,不过这个工具是通过查询还是什么方式 不清楚
如何能不删除目的数据库中多出来的表
比如:目的DB 比 源DB 多出来一个表t1
在执行:mysql-schema-sync -conf mydb_conf.json 2>/dev/null >db_alter.sql
文件 db_alter.sql 中会有一个 drop table t1 的语句
咱们项目的 readme 中提到 “默认情况不会对多出的表、字段、索引、外键删除”
但还是会执行 drop 操作,这里是不是存在BUG ?
因为我的网络原因 无法通过go install 进行安装
我是否能将master.zip 下载下来进行编译呢?
有需要的,我可以放到github上
2019/12/30 schemaSync.go:270: Index : 73 Table : sheet_histories
2019/12/30 db.go:86: [SQL] [source] show create table sheet_histories
[]
2019/12/30 db.go:86: [SQL] [dest] show create table sheet_histories
[]
2019/12/30 index.go:113: db_index parse failed,unsupported,line: ) ENGINE=InnoDB AUTO_INCREMENT=7814 DEFAULT CHARSET=utf8
what does this mean
大佬您好,可否在后续版本,新增表同步数据功能
1、全表同步 正确
2、修改 源 库 表 字段,同步 失败(sql 打印正确,好似没执行sql)
show create table xx_activeuser_usage
CREATE TABLE xx_activeuser_usage
(
account_id
varchar(36) NOT NULL,
host_id
varchar(36) NOT NULL,
start_date
date NOT NULL,
PRIMARY KEY (account_id
,start_date
,host_id
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
/*!50100 PARTITION BY RANGE (TO_DAYS (start_date))
(PARTITION p201510 VALUES LESS THAN (736268) ENGINE = InnoDB,
PARTITION p201511 VALUES LESS THAN (736298) ENGINE = InnoDB,
PARTITION p201512 VALUES LESS THAN (736329) ENGINE = InnoDB,
PARTITION p201601 VALUES LESS THAN (736360) ENGINE = InnoDB,
PARTITION p201602 VALUES LESS THAN (736389) ENGINE = InnoDB,
PARTITION p201603 VALUES LESS THAN (736420) ENGINE = InnoDB,
PARTITION p201604 VALUES LESS THAN (736450) ENGINE = InnoDB,
PARTITION p201605 VALUES LESS THAN (736481) ENGINE = InnoDB,
PARTITION p201606 VALUES LESS THAN (736511) ENGINE = InnoDB,
PARTITION p201812 VALUES LESS THAN (737425) ENGINE = InnoDB) */
求教数据库用户的密码包含了特殊字符的情况怎么转义?
2020/07/21 db.go:71: Error 1146: Table 'clj.test1' doesn't exist
2020/07/21 index.go:113: db_index parse failed,unsupported,line: ) ENGINE=InnoDB DEFAULT CHARSET=utf8
test1 表没有索引
数据库在防火墙后面,需要通过SSH隧道进行连接,希望能添加此功能
json配置项说明
source: 数据库同步源
dest: 待同步的数据库
但是
-dest string
mysql 同步源,eg test@(127.0.0.1:3306)/test_0
-source string
待同步的数据库 eg: test@(10.10.0.1:3306)/test_1
换成 go get github.com/hidu/mysql-schema-sync@latest
提示 go get github.com/hidu/mysql-schema-sync@latest: can't request explicit version of path in main module
大佬出个简单的使用教程吧,这还没入门就跪了
该方案是只支持将数据结构从一个库同步到另一个库,还是同样也支持同一个库里主表和分表的结构同步
试了下当前版本不支持trigger
What i done as fellow:
Mac004:home$ uname home$ which go
Darwin
Mac004:
/usr/local/go/bin/go
Mac004:~ home$ go get -u github.com/hidu/mysql-schema-sync
after 5s
Mac004:~ home$
I do not know what should i do. can you help me?
两个阿里云RDS同步,生成sql脚本,里面没有任何信息。去掉 2>/dev/null 看到查询都是空。
在同一个实例里两个库同步是正常的。
tidb不支持同时修改多个字段,多个字段需要拆分成多个alter语句
使用-single_schema_change会生成多个相同的sql语句,执行起来会有问题
2019/06/13 db.go:85: [SQL] [source] show table status []
2019/06/13 schemaSync.go:265: source db table total: 1
2019/06/13 schemaSync.go:270: Index : 0 Table : test
2019/06/13 schemaSync.go:277: Table: test skip
2019/06/13 schemaSync.go:303: trace changedTables: map[]
2019/06/13 schemaSync.go:352: execute_all_sql_done,success_total: 0 failed_total: 0
2019/06/13 statics.go:137: no table change,skip send mail
{
"source":"root:root@(192.168.1.189:3306)/test",
"dest":"root:root@(192.168.1.189:3306)/test2",
"tables":[],
"email":{
"send_mail":true,
"smtp_host":"",
"from":"",
"password":"",
"to":""
}
}
是否考虑出Windows版本
source ---> dest
从邮件来看:
1.source有表,dest没有
2.after没了,alter after也没有
触发的操作:drop table table_name
然后在同步一 遍
mysql-schema-sync命令找不到
目前很多微服务都是独立的数据库,如果用这个工具,只能每个数据库配一条,建议增加多数据库支持,或者至少可以把配置写在同一个文件
能否增加新的参数,可以让用户指定 字符集的 COLLATE
func (cfg *Config) CheckMatchIgnoreTables(name string) bool {
if len(cfg.TablesIGNORE) == 0 {
return true // ****should return false****
}
for _, tableName := range cfg.TablesIGNORE {
if simpleMatch(tableName, name, "CheckMatchTables") {
return true
}
}
return false
}
请问这是什么错?
2017/10/09 index.go:111: db_index parse failed,unsupport,line: ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
CREATE TABLE `tab_test` (
`test_id` bigint(20) unsigned NOT NULL COMMENT 'id',
`test_str` varchar(128) DEFAULT NULL,
`test_time` int(11) unsigned NOT NULL COMMENT '时间戳',
KEY `test_id` (`test_id`) USING BTREE,
KEY `login_time` (`test_time`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='test'
/*!50100 PARTITION BY HASH (test_id)
PARTITIONS 10 */;
index.go:111: db_index parse failed,unsupport,line: ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='test'
root@ZabbixServer:~/downloads/go/src/github.com/hidu/mysql-schema-sync# ./mysql-schema-sync -conf config.json -sync
2019/05/29 db.go:85: [SQL] [source] show table status []
2019/05/29 schemaSync.go:265: source db table total: 85
2019/05/29 schemaSync.go:270: Index : 0 Table : ti_account
2019/05/29 schemaSync.go:277: Table: ti_account skip
2019/05/29 schemaSync.go:270: Index : 1 Table : ti_account_activity_collect
2019/05/29 schemaSync.go:277: Table: ti_account_activity_collect skip
2019/05/29 schemaSync.go:270: Index : 2 Table : ti_account_attention_act
2019/05/29 schemaSync.go:277: Table: ti_account_attention_act skip
2019/05/29 schemaSync.go:270: Index : 3 Table : ti_account_auth
2019/05/29 schemaSync.go:277: Table: ti_account_auth skip
2019/05/29 schemaSync.go:270: Index : 4 Table : ti_account_auth_backup
2019/05/29 schemaSync.go:277: Table: ti_account_auth_backup skip
2019/05/29 schemaSync.go:270: Index : 5 Table : ti_account_blacklist
2019/05/29 schemaSync.go:277: Table: ti_account_blacklist skip
2019/05/29 schemaSync.go:270: Index : 6 Table : ti_account_cover
2019/05/29 schemaSync.go:277: Table: ti_account_cover skip
2019/05/29 schemaSync.go:270: Index : 7 Table : ti_account_cover_edit_verify
2019/05/29 schemaSync.go:277: Table: ti_account_cover_edit_verify skip
2019/05/29 schemaSync.go:270: Index : 8 Table : ti_account_destroy
2019/05/29 schemaSync.go:277: Table: ti_account_destroy skip
2019/05/29 schemaSync.go:270: Index : 9 Table : ti_account_edit_record
2019/05/29 schemaSync.go:277: Table: ti_account_edit_record skip
2019/05/29 schemaSync.go:270: Index : 10 Table : ti_account_edit_verify
2019/05/29 schemaSync.go:277: Table: ti_account_edit_verify skip
2019/05/29 schemaSync.go:270: Index : 11 Table : ti_account_intent
2019/05/29 schemaSync.go:277: Table: ti_account_intent skip
2019/05/29 schemaSync.go:270: Index : 12 Table : ti_account_invite
2019/05/29 schemaSync.go:277: Table: ti_account_invite skip
2019/05/29 schemaSync.go:270: Index : 13 Table : ti_account_last_edit_log
2019/05/29 schemaSync.go:277: Table: ti_account_last_edit_log skip
版本:20220311.2
实际并没有成功去掉 AUTO_INCREMENT=xxx
也就是说,在json里只需指定默认库名,而执行时,去扫描所有库下的所有表
请问支持不同的机房之间的mysql同步吗?
是否需加上适用的mysql版本号,哪些版本是支持的,哪些版本不支持。
after I ran the script,I got the message below:
email.go:76: send mail failed,err: x509: certificate is valid for *.263.net, 263.net, not smtp.xxxx.com
what's wrong with it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.