安装与状态检查
本页覆盖 Chat2DB CLI 的安装、版本检查、状态检查、运行时检查和 shell completion。建议所有 CLI 操作都从 version 和 status 开始。
安装 CLI
macOS shell:
curl -fsSL https://cdn.chat2db-ai.com/install/cli.sh | shWindows PowerShell:
iwr https://cdn.chat2db-ai.com/install/cli.ps1 -UseBasicParsing | iex安装完成后重新打开终端,确认命令可用:
command -v chat2db
chat2db version --json示例输出:
{"data":{"command":"version","version":"0.1.25"},"ok":true}检查当前状态
chat2db status --jsonstatus 会同时检查 Chat2DB Pro / Local 的 App、CLI runtime 和 MCP 状态。重点看这些字段:
| 字段 | 含义 |
|---|---|
data.cli_version | 当前 CLI 版本 |
summary.pro.app.state | Pro 应用是否运行 |
summary.pro.cli.state | Pro CLI runtime 是否运行 |
summary.pro.mcp.enabled | Pro MCP 是否已启用 |
summary.local.* | Local 对应状态 |
next_action | CLI 建议的下一步操作 |
safe_to_exit | 当前 edition 是否可以安全退出 |
常见状态:
| 状态 | 说明 |
|---|---|
running | 对应进程或 runtime 正在运行 |
stopped | 未运行 |
not_installed | 本机没有安装对应 edition |
alive | MCP endpoint 可访问 |
not_listening | MCP 端口未监听 |
ambiguous | 状态不唯一,通常需要先停止另一个 edition 或重新检查 |
安装 Chat2DB Pro / Local
CLI 可以安装或更新桌面应用。默认安装 Pro:
chat2db install --edition pro --json安装 Local:
chat2db install --edition local --json只查看将要执行什么,不下载、不写入:
chat2db install --edition pro --dry-run --json后台安装:
chat2db install --edition all --background --json后台安装日志见 更新与排障。
启动和停止应用
打开 Pro:
chat2db start --edition pro --json停止 Pro:
chat2db stop --edition pro --json停止 Pro 的 App、CLI runtime 和 MCP:
chat2db stop --edition pro --all --json--all 会影响本机运行状态,适合清理异常进程或准备退出。
CLI runtime
runtime 是 CLI 执行数据源和 SQL 命令时使用的本机 headless runtime。它监听 127.0.0.1,通常会被 db / sql 命令自动启动。
chat2db runtime status --edition pro --json
chat2db runtime start --edition pro --json
chat2db runtime stop --edition pro --json如果 db 或 sql 命令失败,先看:
chat2db status --json
chat2db runtime status --edition pro --jsonShell completion
安装当前 shell 的补全:
chat2db completions --install指定 shell:
chat2db completions --shell zsh
chat2db completions --shell bash
chat2db completions --install --shell fish--install 会写入本机 shell 配置或 completion 目录。只想预览脚本时,不要加 --install。
常见问题
chat2db 命令不存在
重新打开终端,或检查安装目录是否在 PATH 中:
command -v chat2db如果仍然不存在,重新执行 CLI 安装命令。
App 未安装
status 中如果出现 not_installed,先安装对应 edition:
chat2db install --edition pro --json状态显示 ambiguous
通常表示端口或进程状态不唯一。先查看两个 edition:
chat2db status --json如果要清理 Pro:
chat2db stop --edition pro --all --json