📣

TiDB Cloud Serverless 现已更名为
Starter
!此页面由 AI 自动翻译,英文原文请见
此处。

TiDB Cloud CLI 参考(Beta)

TiDB Cloud CLI 是一个命令行界面,允许你通过几行命令在终端中操作 TiDB Cloud。在 TiDB Cloud CLI 中,你可以轻松管理 TiDB Cloud 集群、向集群导入数据以及执行更多操作。

开始之前

请确保你已先完成 TiDB Cloud CLI 环境的设置。安装好 ticloud CLI 后,你就可以通过命令行管理 TiDB Cloud 集群。

可用命令

下表列出了 TiDB Cloud CLI 支持的命令。

在终端中使用 ticloud CLI 时,运行 ticloud [command] [subcommand]。如果你使用的是 TiUP,则使用 tiup cloud [command] [subcommand]

CommandSubcommandDescription
authlogin, logout, whoami登录与登出
serverless (alias: s)create, delete, describe, list, update, spending-limit, region, shell管理 TiDB Cloud Serverless 集群
serverless branchcreate, delete, describe, list, shell管理 TiDB Cloud Serverless 分支
serverless importcancel, describe, list, start管理 TiDB Cloud Serverless 导入任务
serverless exportcreate, describe, list, cancel, download管理 TiDB Cloud Serverless 导出任务
serverless sql-usercreate, list, delete, update管理 TiDB Cloud Serverless SQL 用户
serverless audit-logconfig, describe, filter-rule (alias: filter), download管理 TiDB Cloud Serverless 数据库审计日志
ai-与 TiDB Bot 聊天
completionbash, fish, powershell, zsh为指定 shell 生成补全脚本
configcreate, delete, describe, edit, list, set, use配置用户配置文件
projectlist管理项目
upgrade-将 CLI 升级到最新版本
helpauth, config, serverless, ai, project, upgrade, help, completion查看任意命令的帮助信息

命令模式

TiDB Cloud CLI 针对部分命令提供了两种模式,便于使用:

  • 交互模式

    你可以在不带参数的情况下运行命令(如 ticloud config create),CLI 会提示你输入相关信息。

  • 非交互模式

    你需要在运行命令时提供所有必需的参数和选项,例如 ticloud config create --profile-name <profile-name> --public-key <public-key> --private-key <private-key>

用户配置文件

对于 TiDB Cloud CLI,用户配置文件是与用户相关的一组属性,包括配置文件名称、公钥、私钥和 OAuth token。要使用 TiDB Cloud CLI,你必须拥有一个用户配置文件。

使用 TiDB Cloud API key 创建用户配置文件

使用 ticloud config create 创建用户配置文件。

使用 OAuth token 创建用户配置文件

使用 ticloud auth login 为当前配置文件分配 OAuth token。如果不存在任何配置文件,则会自动创建一个名为 default 的配置文件。

列出所有用户配置文件

使用 ticloud config list 列出所有用户配置文件。

示例输出如下:

Profile Name default (active) dev staging

在此示例输出中,default 用户配置文件为当前激活状态。

查看用户配置文件详情

使用 ticloud config describe 获取用户配置文件的属性。

示例输出如下:

{ "private-key": "xxxxxxx-xxx-xxxxx-xxx-xxxxx", "public-key": "Uxxxxxxx" }

设置用户配置文件属性

使用 ticloud config set 设置用户配置文件中的属性。

切换到其他用户配置文件

使用 ticloud config use 切换到其他用户配置文件。

示例输出如下:

Current profile has been changed to default

编辑配置文件

使用 ticloud config edit 打开配置文件进行编辑。

删除用户配置文件

使用 ticloud config delete 删除用户配置文件。

全局参数

下表列出了 TiDB Cloud CLI 的全局参数。

FlagDescriptionRequiredNote
--no-color禁用输出中的颜色。No仅在非交互模式下生效。在交互模式下,禁用颜色可能会影响部分 UI 组件的显示。
-P, --profile string指定本次命令使用的激活用户配置文件。No适用于非交互和交互模式。
-D, --debug启用调试模式No适用于非交互和交互模式。

反馈

如果你对 TiDB Cloud CLI 有任何问题或建议,欢迎在 issue 页面提交。同时也欢迎任何贡献。

文档内容是否有帮助?