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

> Amazon QuickSight 通过统一的商业智能（BI）为数据驱动型组织提供支持。

# QuickSight

export const ClickHouseSupportedBadge = () => {
  return <div className="ClickHouseSupportedBadge">
            <div className="ClickHouseSupportedIcon">
                <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                    <path d="M1.30762 1.39073C1.30762 1.3103 1.37465 1.22986 1.46849 1.22986H2.64824C2.72868 1.22986 2.80912 1.29689 2.80912 1.39073V14.4886C2.80912 14.5691 2.74209 14.6495 2.64824 14.6495H1.46849C1.38805 14.6495 1.30762 14.5825 1.30762 14.4886V1.39073Z" fill="currentColor" />
                    <path d="M4.2832 1.39073C4.2832 1.3103 4.35023 1.22986 4.44408 1.22986H5.62383C5.70427 1.22986 5.7847 1.29689 5.7847 1.39073V14.4886C5.7847 14.5691 5.71767 14.6495 5.62383 14.6495H4.44408C4.36364 14.6495 4.2832 14.5825 4.2832 14.4886V1.39073Z" fill="currentColor" />
                    <path d="M7.25977 1.39073C7.25977 1.3103 7.3268 1.22986 7.42064 1.22986H8.60039C8.68083 1.22986 8.76127 1.29689 8.76127 1.39073V14.4886C8.76127 14.5691 8.69423 14.6495 8.60039 14.6495H7.42064C7.3402 14.6495 7.25977 14.5825 7.25977 14.4886V1.39073Z" fill="currentColor" />
                    <path d="M10.2354 1.39073C10.2354 1.3103 10.3024 1.22986 10.3962 1.22986H11.576C11.6564 1.22986 11.7369 1.29689 11.7369 1.39073V14.4886C11.7369 14.5691 11.6698 14.6495 11.576 14.6495H10.3962C10.3158 14.6495 10.2354 14.5825 10.2354 14.4886V1.39073Z" fill="currentColor" />
                    <path d="M13.2256 6.6057C13.2256 6.52526 13.2926 6.44482 13.3865 6.44482H14.5662C14.6466 6.44482 14.7271 6.51186 14.7271 6.6057V9.27354C14.7271 9.35398 14.6601 9.43442 14.5662 9.43442H13.3865C13.306 9.43442 13.2256 9.36739 13.2256 9.27354V6.6057Z" fill="currentColor" />
                </svg>
            </div>
            支持 ClickHouse
        </div>;
};

export const Image = ({img, alt, size = "lg"}) => {
  const normalizedSize = ["sm", "md", "lg"].includes(size) ? size : "lg";
  return <div className={`ch-image-${normalizedSize}`}>
      <Frame>
        <img src={img} alt={alt} />
      </Frame>
    </div>;
};

QuickSight 可通过 MySQL 接口，使用官方 MySQL 数据源和 Direct Query 模式连接到本地部署的 ClickHouse (23.11+) 。

<div id="on-premise-clickhouse-server-setup">
  ## 本地部署 ClickHouse 服务器设置
</div>

有关如何配置启用 MySQL 接口的 ClickHouse 服务器，请参阅[官方文档](/zh/concepts/features/interfaces/mysql)。

除了在服务器的 `config.xml` 中添加一个条目之外

```xml theme={null}
<clickhouse>
    <mysql_port>9004</mysql_port>
</clickhouse>
```

对于将通过 MySQL 接口 连接的用户，还*必须*使用 [Double SHA1 密码加密](/zh/concepts/features/configuration/settings/settings-users#user-namepassword)。

在 shell 中生成一个经 Double SHA1 加密的随机密码：

```shell theme={null}
PASSWORD=$(base64 < /dev/urandom | head -c16); echo "$PASSWORD"; echo -n "$PASSWORD" | sha1sum | tr -d '-' | xxd -r -p | sha1sum | tr -d '-'
```

输出应类似于以下内容：

```text theme={null}
LZOQYnqQN4L/T6L0
fbc958cc745a82188a51f30de69eebfc67c40ee4
```

第一行是生成的密码，第二行是可用于配置 ClickHouse 的哈希值。

下面是 `mysql_user` 的一个示例配置，使用了生成的哈希值：

`/etc/clickhouse-server/users.d/mysql_user.xml`

```xml theme={null}
<users>
    <mysql_user>
        <password_double_sha1_hex>fbc958cc745a82188a51f30de69eebfc67c40ee4</password_double_sha1_hex>
        <networks>
            <ip>::/0</ip>
        </networks>
        <profile>default</profile>
        <quota>default</quota>
    </mysql_user>
</users>
```

将 `password_double_sha1_hex` 条目替换为你自己生成的 Double SHA1 哈希值。

QuickSight 要求在 MySQL user 的 profile 中添加若干额外设置。

`/etc/clickhouse-server/users.d/mysql_user.xml`

```xml theme={null}
<profiles>
    <default>
        <prefer_column_name_to_alias>1</prefer_column_name_to_alias>
        <mysql_map_string_to_text_in_show_columns>1</mysql_map_string_to_text_in_show_columns>
        <mysql_map_fixed_string_to_text_in_show_columns>1</mysql_map_fixed_string_to_text_in_show_columns>
    </default>
</profiles>
```

不过，建议将其分配给另一个 profile，供你的 MySQL user 使用，而不要使用默认的 profile。

最后，配置 ClickHouse 服务器 使其监听所需的 IP 地址。
在 `config.xml` 中，取消注释以下内容以监听所有地址：

```bash theme={null}
<listen_host>::</listen_host>
```

如果你本机可用 `mysql` 可执行文件，就可以通过命令行测试连接。
使用上文中的示例用户名 (`mysql_user`) 和密码 (`LZOQYnqQN4L/T6L0`) ，命令行如下所示：

```bash theme={null}
mysql --protocol tcp -h localhost -u mysql_user -P 9004 --password=LZOQYnqQN4L/T6L0
```

```response theme={null}
mysql> show databases;
+--------------------+
| name               |
+--------------------+
| INFORMATION_SCHEMA |
| default            |
| information_schema |
| system             |
+--------------------+
4 rows in set (0.00 sec)
Read 4 rows, 603.00 B in 0.00156 sec., 2564 rows/sec., 377.48 KiB/sec.
```

<div id="connecting-quicksight-to-clickhouse">
  ## 将 QuickSight 连接到 ClickHouse
</div>

首先，前往 [https://quicksight.aws.amazon.com](https://quicksight.aws.amazon.com)，进入 Datasets，然后点击“New dataset”：

<Image size="md" img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/svLCKm9RWi4jibqG/images/integrations/data-visualization/quicksight_01.webp?fit=max&auto=format&n=svLCKm9RWi4jibqG&q=85&s=49b1475d7a434f610ae6cf35c3f40e42" alt="Amazon QuickSight 仪表板，显示 Datasets 部分中的 New dataset 按钮" border width="1555" height="1038" data-path="images/integrations/data-visualization/quicksight_01.webp" />

<br />

搜索 QuickSight 附带的官方 MySQL 连接器 (名称就是 **MySQL**) ：

<Image size="md" img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/svLCKm9RWi4jibqG/images/integrations/data-visualization/quicksight_02.webp?fit=max&auto=format&n=svLCKm9RWi4jibqG&q=85&s=cc25cccdea446662d9957a7433f0281f" alt="QuickSight 数据源选择界面，搜索结果中高亮显示了 MySQL" border width="2006" height="1040" data-path="images/integrations/data-visualization/quicksight_02.webp" />

<br />

填写连接信息。请注意，MySQL 接口的默认端口是 9004，
具体端口可能会因服务器配置而有所不同。

<Image size="md" img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/svLCKm9RWi4jibqG/images/integrations/data-visualization/quicksight_03.webp?fit=max&auto=format&n=svLCKm9RWi4jibqG&q=85&s=8d12ce47aad260d73c210d436d39653c" alt="QuickSight MySQL 连接配置表单，包含 hostname、端口、database 和凭证字段" border width="1059" height="1143" data-path="images/integrations/data-visualization/quicksight_03.webp" />

<br />

现在，您有两种方式可以从 ClickHouse 获取数据。首先，您可以从列表中选择一张表：

<Image size="md" img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/svLCKm9RWi4jibqG/images/integrations/data-visualization/quicksight_04.webp?fit=max&auto=format&n=svLCKm9RWi4jibqG&q=85&s=c906b615fff9e0b735fc0df219a06b35" alt="QuickSight 表选择界面，显示来自 ClickHouse 的可用数据库表" border width="1061" height="845" data-path="images/integrations/data-visualization/quicksight_04.webp" />

<br />

或者，您也可以指定自定义 SQL 来获取数据：

<Image size="md" img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/svLCKm9RWi4jibqG/images/integrations/data-visualization/quicksight_05.webp?fit=max&auto=format&n=svLCKm9RWi4jibqG&q=85&s=8d200a00f885e178c7279ca430ec0aa8" alt="用于从 ClickHouse 获取数据的 QuickSight 自定义 SQL 查询编辑器" border width="1061" height="845" data-path="images/integrations/data-visualization/quicksight_05.webp" />

<br />

点击“Edit/Preview data”后，您应该能够看到识别出的表结构；如果您选择的是自定义 SQL 方式，也可以在这里进行调整：

<Image size="md" img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/svLCKm9RWi4jibqG/images/integrations/data-visualization/quicksight_06.webp?fit=max&auto=format&n=svLCKm9RWi4jibqG&q=85&s=29b929b76b27810accdf9c118a0ddc6e" alt="QuickSight 数据预览，显示包含列和样本数据的表结构" border width="1743" height="1277" data-path="images/integrations/data-visualization/quicksight_06.webp" />

<br />

请确保在 UI 左下角选择了“Direct Query”模式：

<Image size="md" img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/svLCKm9RWi4jibqG/images/integrations/data-visualization/quicksight_07.webp?fit=max&auto=format&n=svLCKm9RWi4jibqG&q=85&s=e17b486cb3b7a2a0109569697b38dbe8" alt="QuickSight 界面，底角高亮显示了 Direct Query 模式选项" border width="677" height="341" data-path="images/integrations/data-visualization/quicksight_07.webp" />

<br />

现在，您可以继续发布数据集并创建新的可视化！

<div id="known-limitations">
  ## 已知限制
</div>

* SPICE 导入未能如预期正常工作；请改用 Direct Query 模式。参见 [#58553](https://github.com/ClickHouse/ClickHouse/issues/58553)。
