> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-fbfa8bee.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> DBeaver 是一款跨平台数据库工具。

# 将 DBeaver 连接到 ClickHouse

export const PartnerBadge = () => {
  return <div className="PartnerBadge">
            <div className="PartnerBadgeIcon">
                <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                    <polyline points="12.5 9.5 10 12 6 11 2.5 8.5" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="1" />
                    <polyline points="4.54 4.41 8 3.5 11.46 4.41" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="1" />
                    <path d="M2.15,3.78 L0.55,6.95 A0.5,0.5 0,0,0 0.77,7.62 L2.5,8.5 L4.54,4.41 L2.82,3.55 A0.5,0.5 0,0,0 2.15,3.78 Z" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="1" />
                    <path d="M13.5,8.5 L15.23,7.62 A0.5,0.5 0,0,0 15.45,6.95 L13.85,3.78 A0.5,0.5 0,0,0 13.18,3.55 L11.46,4.41 Z" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="1" />
                    <path d="M11.5,4.5 L9,4.5 L6.15,7.27 A0.5,0.5 0,0,0 6.24,8.05 C7.33,8.74 8.81,8.72 10,7.5 L12.5,9.5 L13.5,8.5" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="1" />
                    <polyline points="7.75 13.5 5.15 12.85 3.5 11.67" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="1" />
                </svg>
            </div>
            合作伙伴集成
        </div>;
};

export const Image = ({img, alt, size}) => {
  return <Frame>
      <img src={img} alt={alt} />
    </Frame>;
};

DBeaver 有多个版本可供选择。本指南使用的是 [DBeaver Community](https://dbeaver.io/)。有关不同版本及其功能，请参见[此处](https://dbeaver.com/edition/)。DBeaver 通过 JDBC 连接到 ClickHouse。

<Note>
  为了更好地支持 ClickHouse 中的 `Nullable` 列，请使用 DBeaver 23.1.0 或更高版本。
</Note>

<div id="1-gather-your-clickhouse-details">
  ## 1. 获取 ClickHouse 连接信息
</div>

DBeaver 使用基于 HTTP(S) 的 JDBC 连接 ClickHouse；你需要准备以下信息：

* 端点
* 端口号
* 用户名
* 密码

<div id="2-download-dbeaver">
  ## 2. 下载 DBeaver
</div>

DBeaver 可在 [https://dbeaver.io/download/](https://dbeaver.io/download/) 下载。

<div id="3-add-a-database">
  ## 3. 添加数据库
</div>

* 通过 **Database > New Database Connection** 菜单，或点击 **Database Navigator** 中的 **New Database Connection** 图标，打开 **Connect to a database** 对话框：

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/amY-JDMREAaO7mx6/images/integrations/sql-clients/dbeaver-add-database.png?fit=max&auto=format&n=amY-JDMREAaO7mx6&q=85&s=1aaa6d5f4f9344e2d996221376f86e82" size="md" border alt="添加新数据库" width="642" height="385" data-path="images/integrations/sql-clients/dbeaver-add-database.png" />

* 选择 **Analytical**，然后选择 **ClickHouse**：

* 构建 JDBC URL。在 **Main** 选项卡中设置 Host、Port、Username、Password 和 Database：

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/amY-JDMREAaO7mx6/images/integrations/sql-clients/dbeaver-host-port.png?fit=max&auto=format&n=amY-JDMREAaO7mx6&q=85&s=2880ca38e699745a52c1cc5c875f3150" size="md" border alt="设置主机名、端口、用户名、密码和数据库名称" width="650" height="654" data-path="images/integrations/sql-clients/dbeaver-host-port.png" />

* 默认情况下，**SSL > Use SSL** 属性未启用；如果要连接到 ClickHouse Cloud 或在 HTTP 端口上要求使用 SSL 的 server，请启用 **SSL > Use SSL**：

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/amY-JDMREAaO7mx6/images/integrations/sql-clients/dbeaver-use-ssl.png?fit=max&auto=format&n=amY-JDMREAaO7mx6&q=85&s=2ff3657152304f63ed59388d36da8332" size="md" border alt="根据需要启用 SSL" width="650" height="654" data-path="images/integrations/sql-clients/dbeaver-use-ssl.png" />

* 测试连接：

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/amY-JDMREAaO7mx6/images/integrations/sql-clients/dbeaver-test-connection.png?fit=max&auto=format&n=amY-JDMREAaO7mx6&q=85&s=8d9a58768ccdb28866e52e67251c8766" size="md" border alt="测试连接" width="650" height="654" data-path="images/integrations/sql-clients/dbeaver-test-connection.png" />

如果 DBeaver 检测到尚未安装 ClickHouse driver，它会提示你下载：

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/amY-JDMREAaO7mx6/images/integrations/sql-clients/dbeaver-download-driver.png?fit=max&auto=format&n=amY-JDMREAaO7mx6&q=85&s=2ed194ee304fbf20c54c19a20dd156f8" size="md" border alt="下载 ClickHouse driver" width="612" height="689" data-path="images/integrations/sql-clients/dbeaver-download-driver.png" />

* 下载 driver 后，再次 **Test** 连接：

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/amY-JDMREAaO7mx6/images/integrations/sql-clients/dbeaver-test-connection.png?fit=max&auto=format&n=amY-JDMREAaO7mx6&q=85&s=8d9a58768ccdb28866e52e67251c8766" size="md" border alt="测试连接" width="650" height="654" data-path="images/integrations/sql-clients/dbeaver-test-connection.png" />

<div id="4-query-clickhouse">
  ## 4. 查询 ClickHouse
</div>

打开查询编辑器并运行查询。

* 右键单击你的连接，然后选择 **SQL Editor > Open SQL Script** 打开查询编辑器：

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/amY-JDMREAaO7mx6/images/integrations/sql-clients/dbeaver-sql-editor.png?fit=max&auto=format&n=amY-JDMREAaO7mx6&q=85&s=51f64d5ed1d4ffb0b5dc40735ddf870e" size="md" border alt="打开 SQL 编辑器" width="636" height="162" data-path="images/integrations/sql-clients/dbeaver-sql-editor.png" />

* 针对 `system.query_log` 的查询示例：

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/amY-JDMREAaO7mx6/images/integrations/sql-clients/dbeaver-query-log-select.png?fit=max&auto=format&n=amY-JDMREAaO7mx6&q=85&s=b8f625368caba59e1e8ad7fb4a046756" size="md" border alt="示例查询" width="712" height="316" data-path="images/integrations/sql-clients/dbeaver-query-log-select.png" />

<div id="next-steps">
  ## 后续步骤
</div>

请参阅 [DBeaver wiki](https://github.com/dbeaver/dbeaver/wiki) 了解 DBeaver 的功能，并参阅 [ClickHouse documentation](/zh/) 了解 ClickHouse 的功能。
