> ## 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.

# MongoDB 字典源

> 将 MongoDB 配置为 ClickHouse 的字典源。

设置示例：

<Tabs>
  <Tab title="DDL">
    ```sql theme={null}
    SOURCE(MONGODB(
        host 'localhost'
        port 27017
        user ''
        password ''
        db 'test'
        collection 'dictionary_source'
        options 'ssl=true'
    ))
    ```

    或使用 URI：

    ```sql theme={null}
    SOURCE(MONGODB(
        uri 'mongodb://localhost:27017/clickhouse'
        collection 'dictionary_source'
    ))
    ```
  </Tab>

  <Tab title="配置文件">
    ```xml theme={null}
    <source>
        <mongodb>
            <host>localhost</host>
            <port>27017</port>
            <user></user>
            <password></password>
            <db>test</db>
            <collection>dictionary_source</collection>
            <options>ssl=true</options>
        </mongodb>
    </source>
    ```

    或使用 URI：

    ```xml theme={null}
    <source>
        <mongodb>
            <uri>mongodb://localhost:27017/test?ssl=true</uri>
            <collection>dictionary_source</collection>
        </mongodb>
    </source>
    ```
  </Tab>
</Tabs>

<br />

设置字段：

| 设置           | 描述                                     |
| ------------ | -------------------------------------- |
| `host`       | MongoDB 主机。                            |
| `port`       | MongoDB 服务器端口。                         |
| `user`       | MongoDB 用户名。                           |
| `password`   | MongoDB 用户密码。                          |
| `db`         | 数据库名称。                                 |
| `collection` | 集合名称。                                  |
| `options`    | MongoDB 连接字符串选项。可选。                    |
| `uri`        | 用于建立连接的 URI (可替代单独的 host/port/db 字段) 。 |

[有关该引擎的更多信息](/zh/reference/engines/table-engines/integrations/mongodb)
