Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce import mysql #13778

Merged
merged 17 commits into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions TOC-tidb-cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@
- start
- [local](/tidb-cloud/ticloud-import-start-local.md)
- [s3](/tidb-cloud/ticloud-import-start-s3.md)
- [mysql](/tidb-cloud/ticloud-import-start-mysql.md)
- project
- [list](/tidb-cloud/ticloud-project-list.md)
- [update](/tidb-cloud/ticloud-update.md)
Expand Down
32 changes: 16 additions & 16 deletions tidb-cloud/ticloud-import-start-local.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,25 @@ ticloud import start local <file-path> --project-id <project-id> --cluster-id <c

In non-interactive mode, you need to manually enter the required flags. In interactive mode, you can just follow CLI prompts to fill them in.

| Flag | Description | Required | Note |
|--------------------------|--------------------------------------|----------|-----------------------------------|
| -c, --cluster-id string | Cluster ID | Yes | Only works in non-interactive mode. |
| --data-format string | Data format (Currently, only `CSV` is supported) | Yes | Only works in non-interactive mode. |
| -h, --help | Help information for this command | No | Works in both non-interactive and interactive modes. |
| -p, --project-id string | Project ID | Yes | Only works in non-interactive mode. |
| --target-database string | Target database to import data to | Yes | Only works in non-interactive mode. |
| --target-table string | Target table to import data to | Yes | Only works in non-interactive mode. |
| Flag | Description | Required | Note |
|--------------------------|----------------------------------------------------------------------------------------------------------------|----------|---------------------------------------------------------------------------|
| --backslash-escape | Parses backslashes inside fields as escape characters for CSV files (`true` by default) | No | Only works in non-interactive mode when `--data-format CSV` is specified. |
| -c, --cluster-id string | Cluster ID | Yes | Only works in non-interactive mode. |
| --data-format string | Data format (Currently, only `CSV` is supported) | Yes | Only works in non-interactive mode. |
| --delimiter string | The delimiter used for quoting for CSV files (`"` by default) | No | Only works in non-interactive mode when `--data-format CSV` is specified. |
| -h, --help | Help information for this command | No | Works in both non-interactive and interactive modes. |
| -p, --project-id string | Project ID | Yes | Only works in non-interactive mode. |
| --separator string | The field separator for CSV files (`,` by default) | No | Only works in non-interactive mode when `--data-format CSV` is specified. |
| --target-database string | Target database to import data to | Yes | Only works in non-interactive mode. |
| --target-table string | Target table to import data to | Yes | Only works in non-interactive mode. |
| --trim-last-separator | Treats separators as the line terminators and trims all trailing separators for CSV files (`false` by default) | No | Only works in non-interactive mode when `--data-format CSV` is specified. |
xuanyu66 marked this conversation as resolved.
Show resolved Hide resolved

## Inherited flags

| Flag | Description | Required | Note |
|-----------------------|------------------------------------------------------------------------------------------------|----------|-------------------------------------------------------------------------------------------------------------------|
| --backslash-escape | Parses backslashes inside fields as escape characters (`true` by default) for CSV files | No | Only works in non-interactive mode when `--data-format CSV` is specified. |
| --delimiter string | Specifies the delimiter used for quoting (`"` by default) for CSV files | No | Only works in non-interactive mode when `--data-format CSV` is specified. |
| --no-color | Disables color in output | No | Only works in non-interactive mode. In interactive mode, disabling color might not work with some UI components. |
| -P, --profile string | Specifies the active [user profile](/tidb-cloud/cli-reference.md#user-profile) used in this command. | No | Works in both non-interactive and interactive modes. |
| --separator string | Specifies the field separator of CSV files (`,` by default) | No | Only works in non-interactive mode when `--data-format CSV` is specified. |
| --trim-last-separator | Treats separators as the line terminators and trims all trailing separators for CSV files | No | Only works in non-interactive mode when `--data-format CSV` is specified. |
| Flag | Description | Required | Note |
|----------------------|------------------------------------------------------------------------------------------------------|----------|------------------------------------------------------------------------------------------------------------------|
| --no-color | Disables color in output | No | Only works in non-interactive mode. In interactive mode, disabling color might not work with some UI components. |
| -P, --profile string | Specifies the active [user profile](/tidb-cloud/cli-reference.md#user-profile) used in this command. | No | Works in both non-interactive and interactive modes. |
xuanyu66 marked this conversation as resolved.
Show resolved Hide resolved

## Feedback

Expand Down
79 changes: 79 additions & 0 deletions tidb-cloud/ticloud-import-start-mysql.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
title: ticloud import start mysql
summary: The reference of `ticloud import start mysql`.
---

# ticloud import start mysql

Import a table from a MySQL-compatible database to a [TiDB Serverless](/tidb-cloud/select-cluster-tier.md#tidb-serverless-beta) cluster:

```shell
ticloud import start mysql [flags]
```

> **Note:**
>
> - Before running this command, make sure that you have installed the `mysql` command-line tool first.
xuanyu66 marked this conversation as resolved.
Show resolved Hide resolved
xuanyu66 marked this conversation as resolved.
Show resolved Hide resolved
> - If the target table already exists in the target database, to use this command for table import, make sure that the target table name is the same as the source table name and add the `skip-create-table` flag to the command.
xuanyu66 marked this conversation as resolved.
Show resolved Hide resolved
> - If the target table does not exist in the target database, executing this command will automatically create a target table with the same name as the source table in the target database.
xuanyu66 marked this conversation as resolved.
Show resolved Hide resolved

## Examples

Start an import task in interactive mode:

```shell
ticloud import start mysql
```

Start an import task in non-interactive mode (using the TiDB Serverless cluster default user `<username-prefix>.root`):

```shell
ticloud import start mysql --project-id <project-id> --cluster-id <cluster-id> --source-host <source-host> --source-port <source-port> --source-user <source-user> --source-password <source-password> --source-database <source-database> --source-table <source-table> --target-database <target-database> --target-password <target-password>
```

Start an import task in non-interactive mode (using a specific user):

```shell
ticloud import start mysql --project-id <project-id> --cluster-id <cluster-id> --source-host <source-host> --source-port <source-port> --source-user <source-user> --source-password <source-password> --source-database <source-database> --source-table <source-table> --target-database <target-database> --target-password <target-password> --target-user <target-user>
```

Start an import task that skips creating the target table if it already exists in the target database:

```shell
ticloud import start mysql --project-id <project-id> --cluster-id <cluster-id> --source-host <source-host> --source-port <source-port> --source-user <source-user> --source-password <source-password> --source-database <source-database> --source-table <source-table> --target-database <target-database> --target-password <target-password> --skip-create-table
```
xuanyu66 marked this conversation as resolved.
Show resolved Hide resolved

> **Note:**
>
> MySQL 8.0 uses `utf8mb4_0900_ai_ci` as the default collation, which is currently not supported by TiDB. If your source table uses the `utf8mb4_0900_ai_ci` collation, before the import, you need to either alter the source table collation to a [supported collation of TiDB](/character-set-and-collation.md#character-sets-and-collations-supported-by-tidb) or manually create the target table in TiDB.

## Flags

In non-interactive mode, you need to manually enter the required flags. In interactive mode, you can just follow CLI prompts to fill them in.

| Flag | Description | Required | Note |
|--------------------------|----------------------------------------------------------------------------|----------|------------------------------------------------------|
| -c, --cluster-id string | Cluster ID | Yes | Only works in non-interactive mode. |
| -h, --help | Help information for this command | No | Works in both non-interactive and interactive modes. |
| -p, --project-id string | Project ID | Yes | Only works in non-interactive mode. |
| --skip-create-table | Skip creating the target table if it already exists in the target database | No | Only works in non-interactive mode. |
| --source-database string | The name of the source MySQL database | Yes | Only works in non-interactive mode. |
| --source-host string | The host of the source MySQL instance | Yes | Only works in non-interactive mode. |
| --source-password string | The password of the source MySQL instance | Yes | Only works in non-interactive mode. |
| --source-port int | The port of the source MySQL instance | Yes | Only works in non-interactive mode. |
| --source-table string | The source table name in the source MySQL database | Yes | Only works in non-interactive mode. |
| --source-user string | The user to login to the source MySQL instance | Yes | Only works in non-interactive mode. |
qiancai marked this conversation as resolved.
Show resolved Hide resolved
| --target-database string | The target database name in TiDB Serverless cluster | Yes | Only works in non-interactive mode. |
| --target-password string | The password of the target TiDB Serverless cluster | Yes | Only works in non-interactive mode. |
| --target-user string | The user to login to the target TiDB Serverless cluster | No | Only works in non-interactive mode. |
qiancai marked this conversation as resolved.
Show resolved Hide resolved

## Inherited flags

| Flag | Description | Required | Note |
|----------------------|------------------------------------------------------------------------------------------------------|----------|------------------------------------------------------------------------------------------------------------------|
| --no-color | Disables color in output | No | Only works in non-interactive mode. In interactive mode, disabling color might not work with some UI components. |
| -P, --profile string | Specifies the active [user profile](/tidb-cloud/cli-reference.md#user-profile) used in this command. | No | Works in both non-interactive and interactive modes. |

## Feedback

If you have any questions or suggestions on the TiDB Cloud CLI, feel free to create an [issue](https://github.com/tidbcloud/tidbcloud-cli/issues/new/choose). Also, we welcome any contributions.
Loading