# Creating a `DM` Data Source (Upstream)

+ **_Step 1_**: Encrypt the data source password
+ **_Step 2_**: Configure a data source (editing a `yaml` file)
+ **_Step 3_**: Create a data source
+ **_Step 4_**: Verify the data source

```
~!@// Step 1@!~
$ tiup dmctl encrypt 'abc!@#123'
MKxn0Qo3m3XOyjCnhEMtsUCm83EhGQDZ/T4=

~!@// Step 2@!~
$ cat ./source-mysql-01.yaml
source-id: ~!@"mysql-replica-01"@!~
from:
  host: "127.0.0.1"
  port: 3306
  user: "root"
  password: "MKxn0Qo3m3XOyjCnhEMtsUCm83EhGQDZ/T4="
```
```
~!@// Step 3@!~
$ tiup dmctl --master-addr {dm_master_address} operate-source create ./source-mysql-01.yaml
{
    "result": true,
    "msg": "",
    "sources": [
        {
            "result": true,
            "msg": "",
            "source": ~!@"mysql-replica-01"@!~,
            "worker": "dm-worker-1"
        }
    ]
}

~!@// Step 4@!~
$ tiup dmctl --master-addr {dm_master_address} operate-source show
{
    "result": true,
    "msg": "",
    "sources": [
        {
            "result": true,
            "msg": "",
            "source": ~!@"mysql-replica-01"@!~,
            "worker": "dm-worker-1"
        }
    ]
}
```
-------------------------------------------------------------
Use command `create` to create one or more upstream database sources. When creating multiple data sources fails, an attempt is made to roll back to the state before the command was executed.

The configuration information of the upstream database (source database) is saved to `conf/sourcen.yaml`. The file mainly contains information such as the source database IP, port number, user name, password, `GTID` setting, relay log setting, etc.

The example file is as follows, assuming it is the first instance of `MySQL`:

```
source-id: "mysql-replica-01"

enable-gtid: false

relay-binlog-name: ""     # Upstream database binlog file name
relay-binlog-gtid: ""     # Upstream database binlog GTID

from:
  host: "127.0.0.1"
  port: 3306
  user: "root"
  password: "MKxn0Qo3m3XOyjCnhEMtsUCm83EhGQDZ/T4="
```

Execute the following command in the terminal to load `MySQL` data source configuration into `DM` cluster using tiup dmctl:

```
tiup dmctl --master-addr 172.16.10.71:8261 operate-source create ./source-mysql-01.yaml
```

Output:
```
{
    "result": true,
    "msg": "",
    "sources": [
        {
            "result": true,
            "msg": "",
            "source": "mysql-replica-01",
            "worker": "dm-worker-1"
        }
    ]
}
```

For the `Nth` instance of `MySQL`, modify the relevant information in the configuration file and execute the same `dmctl` command.

