Skip to content

Commit 10196ab

Browse files
committed
Migrating from MySQL with Addax
1 parent a7d0b3a commit 10196ab

File tree

2 files changed

+105
-99
lines changed

2 files changed

+105
-99
lines changed

docs/en/guides/40-load-data/02-load-db/addax.md

Lines changed: 2 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -18,104 +18,7 @@ DatabendReader and DatabendWriter are integrated plugins of Addax, allowing seam
1818

1919
The DatabendReader plugin enables reading data from Databend. Databend provides compatibility with the MySQL client protocol, so you can also use the [MySQLReader](https://wgzhao.github.io/Addax/develop/reader/mysqlreader/) plugin to retrieve data from Databend. For more information about DatabendReader, see https://wgzhao.github.io/Addax/develop/reader/databendreader/
2020

21-
## Tutorial: Data Loading from MySQL
21+
## Tutorials
2222

23-
In this tutorial, you will load data from MySQL to Databend with Addax. Before you start, make sure you have successfully set up Databend, MySQL, and Addax in your environment.
23+
- [Migrating from MySQL with Addax](/tutorials/migrate/migrating-from-mysql-with-addax)
2424

25-
1. In MySQL, create a SQL user that you will use for data loading and then create a table and populate it with sample data.
26-
27-
```sql title='In MySQL:'
28-
mysql> create user 'mysqlu1'@'%' identified by '123';
29-
mysql> grant all on *.* to 'mysqlu1'@'%';
30-
mysql> create database db;
31-
mysql> create table db.tb01(id int, col1 varchar(10));
32-
mysql> insert into db.tb01 values(1, 'test1'), (2, 'test2'), (3, 'test3');
33-
```
34-
35-
2. In Databend, create a corresponding target table.
36-
37-
```sql title='In Databend:'
38-
databend> create database migrated_db;
39-
databend> create table migrated_db.tb01(id int null, col1 String null);
40-
```
41-
42-
3. Copy and paste the following code to a file, and name the file as *mysql_demo.json*:
43-
44-
:::note
45-
For the available parameters and their descriptions, refer to the documentation provided at the following link: https://wgzhao.github.io/Addax/develop/writer/databendwriter/#_2
46-
:::
47-
48-
```json title='mysql_demo.json'
49-
{
50-
"job": {
51-
"setting": {
52-
"speed": {
53-
"channel": 4
54-
}
55-
},
56-
"content": {
57-
"writer": {
58-
"name": "databendwriter",
59-
"parameter": {
60-
"preSql": [
61-
"truncate table @table"
62-
],
63-
"postSql": [
64-
],
65-
"username": "u1",
66-
"password": "123",
67-
"database": "migrate_db",
68-
"table": "tb01",
69-
"jdbcUrl": "jdbc:mysql://127.0.0.1:3307/migrated_db",
70-
"loadUrl": ["127.0.0.1:8000","127.0.0.1:8000"],
71-
"fieldDelimiter": "\\x01",
72-
"lineDelimiter": "\\x02",
73-
"column": ["*"],
74-
"format": "csv"
75-
}
76-
},
77-
"reader": {
78-
"name": "mysqlreader",
79-
"parameter": {
80-
"username": "mysqlu1",
81-
"password": "123",
82-
"column": [
83-
"*"
84-
],
85-
"connection": [
86-
{
87-
"jdbcUrl": [
88-
"jdbc:mysql://127.0.0.1:3306/db"
89-
],
90-
"driver": "com.mysql.jdbc.Driver",
91-
"table": [
92-
"tb01"
93-
]
94-
}
95-
]
96-
}
97-
}
98-
}
99-
}
100-
}
101-
```
102-
103-
4. Run Addax:
104-
105-
```shell
106-
cd {YOUR_ADDAX_DIR_BIN}
107-
./addax.sh -L debug ./mysql_demo.json
108-
```
109-
110-
You're all set! To verify the data loading, execute the query in Databend:
111-
112-
```sql
113-
databend> select * from migrated_db.tb01;
114-
+------+-------+
115-
| id | col1 |
116-
+------+-------+
117-
| 1 | test1 |
118-
| 2 | test2 |
119-
| 3 | test3 |
120-
+------+-------+
121-
```
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
---
2+
title: Migrating from MySQL with Addax
3+
---
4+
5+
In this tutorial, you will load data from MySQL to Databend with Addax. Before you start, make sure you have successfully set up Databend, MySQL, and Addax in your environment.
6+
7+
1. In MySQL, create a SQL user that you will use for data loading and then create a table and populate it with sample data.
8+
9+
```sql title='In MySQL:'
10+
mysql> create user 'mysqlu1'@'%' identified by '123';
11+
mysql> grant all on *.* to 'mysqlu1'@'%';
12+
mysql> create database db;
13+
mysql> create table db.tb01(id int, col1 varchar(10));
14+
mysql> insert into db.tb01 values(1, 'test1'), (2, 'test2'), (3, 'test3');
15+
```
16+
17+
2. In Databend, create a corresponding target table.
18+
19+
```sql title='In Databend:'
20+
databend> create database migrated_db;
21+
databend> create table migrated_db.tb01(id int null, col1 String null);
22+
```
23+
24+
3. Copy and paste the following code to a file, and name the file as *mysql_demo.json*:
25+
26+
:::note
27+
For the available parameters and their descriptions, refer to the documentation provided at the following link: https://wgzhao.github.io/Addax/develop/writer/databendwriter/#_2
28+
:::
29+
30+
```json title='mysql_demo.json'
31+
{
32+
"job": {
33+
"setting": {
34+
"speed": {
35+
"channel": 4
36+
}
37+
},
38+
"content": {
39+
"writer": {
40+
"name": "databendwriter",
41+
"parameter": {
42+
"preSql": [
43+
"truncate table @table"
44+
],
45+
"postSql": [
46+
],
47+
"username": "u1",
48+
"password": "123",
49+
"database": "migrate_db",
50+
"table": "tb01",
51+
"jdbcUrl": "jdbc:mysql://127.0.0.1:3307/migrated_db",
52+
"loadUrl": ["127.0.0.1:8000","127.0.0.1:8000"],
53+
"fieldDelimiter": "\\x01",
54+
"lineDelimiter": "\\x02",
55+
"column": ["*"],
56+
"format": "csv"
57+
}
58+
},
59+
"reader": {
60+
"name": "mysqlreader",
61+
"parameter": {
62+
"username": "mysqlu1",
63+
"password": "123",
64+
"column": [
65+
"*"
66+
],
67+
"connection": [
68+
{
69+
"jdbcUrl": [
70+
"jdbc:mysql://127.0.0.1:3306/db"
71+
],
72+
"driver": "com.mysql.jdbc.Driver",
73+
"table": [
74+
"tb01"
75+
]
76+
}
77+
]
78+
}
79+
}
80+
}
81+
}
82+
}
83+
```
84+
85+
4. Run Addax:
86+
87+
```shell
88+
cd {YOUR_ADDAX_DIR_BIN}
89+
./addax.sh -L debug ./mysql_demo.json
90+
```
91+
92+
You're all set! To verify the data loading, execute the query in Databend:
93+
94+
```sql
95+
databend> select * from migrated_db.tb01;
96+
+------+-------+
97+
| id | col1 |
98+
+------+-------+
99+
| 1 | test1 |
100+
| 2 | test2 |
101+
| 3 | test3 |
102+
+------+-------+
103+
```

0 commit comments

Comments
 (0)