> ## Documentation Index
> Fetch the complete documentation index at: https://help.teable.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 启用外部数据库连接

> 在应用中自动创建数据库角色允许外部应用对表格数据的安全访问功能

<img src="https://mintcdn.com/teablecn/1xqYWjz_9sL5LR8T/images/selfhosted/database-connection/2026-05-29-database-connection-overview-zh.png?fit=max&auto=format&n=1xqYWjz_9sL5LR8T&q=85&s=5da4c5d4233c37069ac3028142d09044" alt="外部数据库连接概览" className="docs-screenshot" width="990" height="550" data-path="images/selfhosted/database-connection/2026-05-29-database-connection-overview-zh.png" />

要启用此功能，需要额外配置 `PUBLIC_DATABASE_PROXY` 环境变量

要将该参数配置为外部可访问的数据库 ip 或域名 + 端口号。如果你使用前面的 docker-compose 部署，则外部访问端口为 42345。其他方式请根据具体配置来进行

```
PUBLIC_DATABASE_PROXY=db-proxy.example.com:port
```

## 更多环境变量配置

[环境变量](/zh/deploy/env)
