OtterMind / Chat2DB

OtterMind / Chat2DB

Powered by OtterMind, an AI-powered database client and SQL workspace for developers, DBAs, analysts, and data teams. 由 OtterMind 提供支持,这是一个为开发人员、数据库管理员 (DBA)、分析师和数据团队打造的 AI 驱动型数据库客户端及 SQL 工作区。

What is Chat2DB?

什么是 Chat2DB?

Chat2DB Community is a free, cross-platform database client for Windows, macOS, and Linux. It runs entirely on your machine and combines a full-featured SQL workspace with an AI assistant that you connect to your own model. Chat2DB Community 是一款免费的跨平台数据库客户端,支持 Windows、macOS 和 Linux。它完全在您的本地机器上运行,将功能齐全的 SQL 工作区与可连接至您自有模型的 AI 助手相结合。

  • 30+ databases — MySQL, PostgreSQL, Oracle, SQL Server, ClickHouse, MongoDB, Redis, SQLite, MariaDB, TiDB, Hive, DB2, Snowflake, BigQuery, Elasticsearch, and more via plugins.
  • 30 多种数据库 — 支持 MySQL、PostgreSQL、Oracle、SQL Server、ClickHouse、MongoDB、Redis、SQLite、MariaDB、TiDB、Hive、DB2、Snowflake、BigQuery、Elasticsearch 等,并可通过插件扩展。
  • SQL workspace — editing, completion, formatting, execution, saved SQL, and execution history.
  • SQL 工作区 — 提供编辑、自动补全、格式化、执行、SQL 保存及执行历史记录功能。
  • AI assistant — bring your own AI model to generate, explain, and optimize SQL in natural language.
  • AI 助手 — 使用您自己的 AI 模型,通过自然语言生成、解释和优化 SQL。
  • Database management — browse metadata, manage tables and objects (DDL/DML), and edit data in place.
  • 数据库管理 — 浏览元数据、管理表和对象 (DDL/DML),并直接原地编辑数据。
  • Data import and export, dashboards and charts, and an open-source CLI with MCP support.
  • 数据导入导出、仪表盘与图表,以及支持 MCP 的开源命令行工具 (CLI)。

Screenshots

截图

  • Dashboards and charts (仪表盘与图表)
  • ER diagrams (ER 图)
  • Visual data management (可视化数据管理)
  • Data import and export (数据导入导出)

Quick Start

快速开始

Option 1: Desktop App Download the installer for your platform from GitHub Releases, install it, and start connecting to your databases. No further setup is required. 选项 1:桌面应用程序 从 GitHub Releases 下载适用于您平台的安装程序,安装后即可开始连接数据库。无需其他额外设置。

Option 2: Docker Requirements: Docker 19.03.0+, Docker Compose 2.0.0+ (Compose V2, only for the Compose variant), 2+ CPU cores, 4+ GiB RAM. First create the encryption key (see Encryption Key for why it matters), then start the container: 选项 2:Docker 要求:Docker 19.03.0+,Docker Compose 2.0.0+(Compose V2,仅适用于 Compose 变体),2 核以上 CPU,4 GiB 以上内存。首先创建加密密钥(参阅“加密密钥”部分了解其重要性),然后启动容器:

# Run once from a repository checkout. Re-running reuses the same valid key.
# 从仓库检出后运行一次。重新运行将复用同一个有效密钥。
git clone https://github.com/OtterMind/Chat2DB.git && cd Chat2DB
./script/security/init-community-encryption-key.sh

docker run --detach \
  --name chat2db-community \
  --restart unless-stopped \
  --publish 127.0.0.1:10825:10825 \
  --volume "$HOME/.chat2db-community-docker:/root/.chat2db-community" \
  --env CHAT2DB_COMMUNITY_ENCRYPTION_KEY_FILE=/run/secrets/chat2db-community-encryption.key \
  --volume "$HOME/.config/chat2db-community/encryption.key:/run/secrets/chat2db-community-encryption.key:ro" \
  chat2db/chat2db:latest

Then open http://localhost:10825 in your browser. Alternatively, use the bundled Compose definition: 然后,在浏览器中打开 http://localhost:10825。或者,使用自带的 Compose 定义:

./script/security/init-community-encryption-key.sh
docker compose --file docker/docker-compose.yml up --detach

Notes: To update, pull the new image, remove the old container, and run the start command again. Keep ~/.config/chat2db-community/encryption.key across rebuilds. The docker run example stores application data in $HOME/.chat2db-community-docker; the Compose definition uses the chat2db-community-data named volume. These locations do not share data. Chat2DB Community 5.3.0 uses the independent /root/.chat2db-community directory and does not automatically migrate data from earlier images that used /root/.chat2db. 注意: 如需更新,请拉取新镜像,删除旧容器,然后再次运行启动命令。在重建过程中请保留 ~/.config/chat2db-community/encryption.key。上述 docker run 示例将应用程序数据存储在 $HOME/.chat2db-community-docker 中;而 Compose 定义使用的是名为 chat2db-community-data 的卷。这两个位置的数据不共享。Chat2DB Community 5.3.0 使用独立的 /root/.chat2db-community 目录,不会自动迁移之前使用 /root/.chat2db 的旧镜像数据。


Security Notes

安全须知

Chat2DB Community is a single-user, local-first application. It has no user accounts or authorization boundaries between users. Keep the HTTP service bound to 127.0.0.1 or ::1 and do not expose it to other users or untrusted networks. Custom JDBC drivers are executable Java code — install them only from sources you trust. Imported configuration files, archives, SQL files, database contents, and AI responses remain untrusted data. See the Security Policy for the complete trust boundary and vulnerability reporting process. If you find this project useful, please give us a Star ⭐️ — it really helps! Chat2DB Community 是一款单用户、本地优先的应用程序。它没有用户账户,也不存在用户间的授权边界。请将 HTTP 服务绑定到 127.0.0.1 或 ::1,不要将其暴露给其他用户或不受信任的网络。自定义 JDBC 驱动程序属于可执行的 Java 代码,请仅从您信任的来源安装。导入的配置文件、归档文件、SQL 文件、数据库内容以及 AI 响应均属于不受信任的数据。请参阅安全策略以了解完整的信任边界和漏洞报告流程。如果您觉得本项目有用,请给我们点个 Star ⭐️ — 这对我们非常有帮助!


Encryption Key

加密密钥

Chat2DB Community encrypts stored datasource passwords and AI model API keys with AES-256-GCM using a per-installation key. Create it once from a repository checkout (requires openssl): Chat2DB Community 使用安装时生成的密钥,通过 AES-256-GCM 算法加密存储的数据源密码和 AI 模型 API 密钥。请从仓库检出后创建一次(需要 openssl):

./script/security/init-community-encryption-key.sh

The key is written to ~/.config/chat2db-community/encryption.key. Back this file up separately and keep it across upgrades and container rebuilds — replacing or losing it makes previously stored datasource passwords and AI model API keys unreadable. Web/headless startup fails when no valid key is provided; only Desktop mode creates a missing key automatically. 密钥会被写入 ~/.config/chat2db-community/encryption.key。请单独备份此文件,并在升级和容器重建时保留它——如果替换或丢失该文件,之前存储的数据源密码和 AI 模型 API 密钥将无法读取。在未提供有效密钥的情况下,Web/无头模式启动将失败;只有桌面模式会自动创建缺失的密钥。

Key configuration reference (custom paths, resolution order, validation) 密钥配置参考(自定义路径、解析顺序、验证)

The key must be valid Base64 that decodes to exactly 32 bytes. The bundled initializer generates the standard padded form: 44 Base64 characters ending in =. It is cryptographic key material, not a human-readable password. Datasource passwords and AI API keys use the same key with separate authenticated AAD values, so ciphertext from one purpose cannot be decrypted as the other. 密钥必须是有效的 Base64 编码,解码后正好为 32 字节。自带的初始化程序会生成标准的填充格式:以 = 结尾的 44 个 Base64 字符。这是加密密钥材料,而非人类可读的密码。数据源密码和 AI API 密钥使用相同的密钥,但具有独立的认证 AAD 值,因此一种用途的密文无法被另一种用途解密。

To use a custom path, pass it to the script and configure the same path when starting Chat2DB: 如需使用自定义路径,请将其传递给脚本,并在启动 Chat2DB 时配置相同的路径:

./script/security/init-community-encryption-key.sh /secure/path/chat2db-community.key

java -Dloader.path=chat2db-community-server/chat2db-community-start/target/lib \
  -Dchat2db.runtime.mode=community \
  -Dchat2db.mode=WEB \
  -Dchat2db.gui=false \
  -Dchat2db.network.status=OFFLINE \
  -Dchat2db.community.encryption-key-file=/secure/path/chat2db-community.key \
  -Dserver.address=127.0.0.1 \
  -Dserver.port=10825 \
  -jar chat2db-community-server/chat2db-community-start/target/chat2db-community.jar

The script’s key-file path priority is the positional argument, CHAT2DB_COMMUNITY_ENCRYPTION_KEY_FILE, then the default path. It reuses a valid regular file, rejects symbolic links and non-regular files, and refuses to overwrite an invalid file. Keep the key readable only by the Chat2DB process owner. 脚本对密钥文件路径的优先级处理为:位置参数 > CHAT2DB_COMMUNITY_ENCRYPTION_KEY_FILE > 默认路径。它会复用有效的常规文件,拒绝符号链接和非常规文件,并拒绝覆盖无效文件。请确保密钥仅对 Chat2DB 进程所有者可读。

Key configuration is resolved in this order: 密钥配置按以下顺序解析:

  1. JVM property chat2db.community.encryption-key containing the Base64 key. (包含 Base64 密钥的 JVM 属性 chat2db.community.encryption-key)
  2. Environment variable CHAT2DB_COMMUNITY_ENCRYPTION_KEY containing the Base64 key. (包含 Base64 密钥的环境变量 CHAT2DB_COMMUNITY_ENCRYPTION_KEY)
  3. JVM property chat2db.community.encryption-key-file containing a key-file path. (包含密钥文件路径的 JVM 属性 chat2db.community.encryption-key-file)
  4. Environment variable CHAT2DB_COMMUNITY_ENCRYPTION_KEY_FILE containing a key-file path. (包含密钥文件路径的环境变量 CHAT2DB_COMMUNITY_ENCRYPTION_KEY_FILE)
  5. Default file ~/.config/chat2db-community/encryption.key. (默认文件 ~/.config/chat2db-community/encryption.key)

The first configured value is authoritative. A blank value, malformed Base64, a key that does not decode to 32 bytes, or an invalid key file fails startup instead of falling through to the next source. File-based configuration is recommended because it… 第一个配置的值具有权威性。如果值为空、Base64 格式错误、密钥解码后不足 32 字节或密钥文件无效,启动将直接失败,而不会尝试下一个来源。建议使用基于文件的配置,因为它……