1、datax工具类下载地址
datax工具类下载地址
2. python
安装地址
hi,这是我用百度网盘分享的文件~复制这段内容打开「百度网盘」APP即可获取。
链接:https://pan.baidu.com/s/1TJ4rBXfTGbnp20ROMAXw4w?pwd=KLE3
提取码:KLE3
3. 自检命令
python /opt/datax//bin/datax.py /opt/datax/job/job.json
4.遇到的错误一,找不到配置文件
解决方式:
把工具包中的 plugins里所有带下划线开头的,全删掉
4.数据库导入 first.json
{
"job": {
"setting": {
"speed": {
"channel": 1
}
},
"content": [
{
"reader": {
"name": "mysqlreader",
"parameter": {
"username": "root",
"password": "root",
"column": [ "id", "name","content" ,"createdate"],
"splitPk": "id",
"connection": [
{
"table": [
"t_user_info"
],
"jdbcUrl": [
"jdbc:mysql://127.0.0.1:13306/sourcedb?useUnicode=true&characterEncoding=utf8"
]
}
]
}
},
"writer": {
"name": "mysqlwriter",
"parameter": {
"writeMode": "insert",
"username": "root",
"password": "root",
"column": [ "id", "name","content","createdate"],
"session": [
"set session sql_mode='ANSI'"
],
"preSql": [
"delete from t_user_info"
],
"connection": [
{
"jdbcUrl": "jdbc:mysql://127.0.0.1:13306/targetdb?useUnicode=true&characterEncoding=utf8",
"table": [
"t_user_info"
]
}
]
}
}
}
]
}
}
- 创建source和target数据库
1.建表语句
CREATE TABLE `t_user_info` (
`id` int(0) NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
`content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL,
`createdate` datetime(0) NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of t_user_info
-- ----------------------------
INSERT INTO `t_user_info` VALUES (1, 'linux重启mysql的命令', 'linux重启mysql的命令', '2020-04-19 21:18:58');
INSERT INTO `t_user_info` VALUES (2, 'jQuery给input绑定回车事件', 'jQuery给input绑定回车事件', '2020-04-20 21:19:14');
INSERT INTO `t_user_info` VALUES (3, 'Web开发Session超时设置', 'Web开发Session超时设置', '2020-04-21 21:19:19');
SET FOREIGN_KEY_CHECKS = 1;
- 执行命令
python /opt/datax//bin/datax.py /opt/datax/job/first.json
-
如果出现中文乱码,把数据库改成utf-8。然后再链接地址加上?useUnicode=true&characterEncoding=utf8
-
如果是连接mysql8 更换reader和writer lib目录下的mysql驱动包
mysql8
hi,这是我用百度网盘分享的文件~复制这段内容打开「百度网盘」APP即可获取。
链接:https://pan.baidu.com/s/17tEOecCdwY3YEryuR6ywng?pwd=KLE3
提取码:KLE3