diff --git a/TOC-tidb-cloud.md b/TOC-tidb-cloud.md index 3aec338353b31..a79037d1f30c1 100644 --- a/TOC-tidb-cloud.md +++ b/TOC-tidb-cloud.md @@ -534,6 +534,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) diff --git a/tidb-cloud/get-started-with-cli.md b/tidb-cloud/get-started-with-cli.md index 16f2eca4af30c..47f31093bc395 100644 --- a/tidb-cloud/get-started-with-cli.md +++ b/tidb-cloud/get-started-with-cli.md @@ -42,6 +42,26 @@ For macOS or Linux, you can install `ticloud` using any of the following methods To set up `ticloud` in GitHub Action, use [`setup-tidbcloud-cli`](https://github.com/tidbcloud/setup-tidbcloud-cli). +Install the MySQL command-line client if you do not have it. You can install it via your package manager: + +- Debian-based distributions: + + ```shell + sudo apt-get install mysql-client + ``` + +- RPM-based distributions: + + ```shell + sudo yum install mysql + ``` + +- macOS: + + ```shell + brew install mysql-client + ``` +
@@ -56,6 +76,8 @@ For Windows, you can install `ticloud` using either of the following methods: To set up `ticloud` in GitHub Actions, use [`setup-tidbcloud-cli`](https://github.com/tidbcloud/setup-tidbcloud-cli). +Install the MySQL command-line client if you do not have it. You can refer to the instructions in [MySQL Installer for Windows](https://dev.mysql.com/doc/refman/8.0/en/mysql-installer.html) for the installation. To launch `ticloud connect` on Windows, you need to have the directory containing `mysql.exe` in the PATH environment variable. +
diff --git a/tidb-cloud/ticloud-import-start-local.md b/tidb-cloud/ticloud-import-start-local.md index 1c86739bc41ca..d1bcd7ff80d8f 100644 --- a/tidb-cloud/ticloud-import-start-local.md +++ b/tidb-cloud/ticloud-import-start-local.md @@ -39,25 +39,25 @@ ticloud import start local --project-id --cluster-id **Note:** +> +> - Before running this command, make sure that you have installed the MySQL command-line tool first. For more details, see [Installation](/tidb-cloud/get-started-with-cli.md#installation). +> - 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 in the command. +> - If the target table does not exist in the target database, executing this command automatically creates a table with the same name as the source table in the target database. + +## 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 `.root`): + + ```shell + ticloud import start mysql --project-id --cluster-id --source-host --source-port --source-user --source-password --source-database --source-table --target-database --target-password + ``` + +- Start an import task in non-interactive mode (using a specific user): + + ```shell + ticloud import start mysql --project-id --cluster-id --source-host --source-port --source-user --source-password --source-database --source-table --target-database --target-password --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 --cluster-id --source-host --source-port --source-user --source-password --source-database --source-table --target-database --target-password --skip-create-table + ``` + +> **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 | Specifies the cluster ID. | Yes | Only works in non-interactive mode. | +| -h, --help | Displays help information for this command. | No | Works in both non-interactive and interactive modes. | +| -p, --project-id string | Specifies the project ID. | Yes | Only works in non-interactive mode. | +| --skip-create-table | Skips 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 for 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 log in to the source MySQL instance. | Yes | Only works in non-interactive mode. | +| --target-database string | The target database name in the TiDB Serverless cluster. | Yes | Only works in non-interactive mode. | +| --target-password string | The password for the target TiDB Serverless cluster. | Yes | Only works in non-interactive mode. | +| --target-user string | The user to log in to the target TiDB Serverless cluster. | No | Only works in non-interactive mode. | + +## 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. diff --git a/tidb-cloud/ticloud-import-start-s3.md b/tidb-cloud/ticloud-import-start-s3.md index 7146b08217c4d..d42f84def8128 100644 --- a/tidb-cloud/ticloud-import-start-s3.md +++ b/tidb-cloud/ticloud-import-start-s3.md @@ -39,25 +39,25 @@ ticloud import start s3 --project-id --cluster-id --aw 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 | -|-------------------------|----------------------------------------------------------|----------|-----------------------------------| -| --aws-role-arn string | AWS S3 IAM Role ARN | Yes | Only works in non-interactive mode. | -| -c, --cluster-id string | Cluster ID | Yes | Only works in non-interactive mode. | -| --data-format string | Data format. Valid values are `CSV`, `SqlFile`, `Parquet`, or `AuroraSnapshot`. | 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. | -| --source-url string | The S3 path where the source data files are stored | Yes | Only works in non-interactive mode. | +| Flag | Description | Required | Note | +|---|---|---|---| +| --aws-role-arn string | Specifies the AWS role ARN that is used to access the Amazon S3 data source. | Yes | Only works in non-interactive mode. | +| --backslash-escape | Whether to parse backslashes inside fields as escape characters for CSV files. The default value is `true`. | No | Only works in non-interactive mode when `--data-format CSV` is specified. | +| -c, --cluster-id string | Specifies the cluster ID. | Yes | Only works in non-interactive mode. | +| --data-format string | Specifies the data format. Valid values are `CSV`, `SqlFile`, `Parquet`, or `AuroraSnapshot`. | Yes | Only works in non-interactive mode. | +| --delimiter string | Specifies the delimiter used for quoting for CSV files. The default value is `"`. | No | Only works in non-interactive mode when `--data-format CSV` is specified. | +| -h, --help | Displays help information for this command. | No | Works in both non-interactive and interactive modes. | +| -p, --project-id string | Specifies the project ID. | Yes | Only works in non-interactive mode. | +| --separator string | Specifies the field separator for CSV files. The default value is `,`. | No | Only works in non-interactive mode when `--data-format CSV` is specified. | +| --source-url string | The S3 path where the source data files are stored. | Yes | Only works in non-interactive mode. | +| --trim-last-separator | Whether to treat separators as line terminators and trim all trailing separators for CSV files. The default value is `false`. | No | Only works in non-interactive mode when `--data-format CSV` is specified. | ## 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. | ## Feedback