小编Mar*_*ang的帖子

从 Windows 10 主机连接 WSL2 Ubuntu 中安装的 PostgreSQL 时出现问题

我在从 Windows 10 主机连接到安装在 WSL2 Ubuntu 中的 PostgreSQL 时遇到了很大的麻烦。

这是我到目前为止所做的。

  1. 设置 postgres 用户的密码。
  2. 在 pg_hpa.conf 中设置以下内容

    local all postgres md5

    host all all 0.0.0.0/0 md5

  3. 在 postgresql.conf 中设置以下内容

    listen_addresses = '*'

  4. 测试成功,我可以连接psql -U postgres- 所以密码应该设置正确。

当我尝试从 Windows 10 主机使用 pgAdmin 或 psql 进行连接时,出现以下错误。

error: could not connect to server: FATAL: password authentication failed for user "postgres"

我还可以在 pg_hpa.conf 或其他可能有帮助的 PostgreSQL 配置中更改其他内容吗?

我想我可能与 WSL2 有自己的 IP 有关,即使来自主机的连接看起来来自本地主机。连接似乎已建立,但当不是从 Ubuntu 内部建立时,身份验证会由于某种原因失败。

postgresql wsl-2

6
推荐指数
1
解决办法
6492
查看次数

标签 统计

postgresql ×1

wsl-2 ×1