服务器在连接到 Azure Postgres 时意外关闭连接

ale*_*729 7 postgresql azure azure-sql-database

我正在尝试使用本地机器上的 psql 连接到 Azure Postgresql 并收到以下错误:

$ psql "host=username.postgres.database.azure.com port=5432 dbname=postgres user=username@domain password=mypassword sslmode=require"
psql: error: could not connect to server: server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.
Run Code Online (Sandbox Code Playgroud)

本地 Postgres 版本:12.1,Azure Postgres 数据库版本:10,macOS Majove。

这个问题是在我使用 Homebrew 重新安装 Postgres 后才开始的。我运行没有问题$ psql --host=localhost

我尝试postgresql@10使用自制软件进行安装,以便在运行时psql收到消息psql (12.1, server 10.11)。但是当我尝试登录 Azure Postgres 时,我遇到了与上面相同的错误。

我对 Postgres 和 Azure 还很陌生,希望得到任何建议。

更新:

感谢您的评论和反馈。

我使用 Homebrew 正确安装了 Postgres 10 并将其链接以解决问题。

$ brew services stop postgresql
$ brew install postgresql@10
$ brew services start postgresql@10
$ brew link --overwrite --force postgresql@10
Run Code Online (Sandbox Code Playgroud)

我现在可以按预期访问 Azure 数据库。

Nan*_*ong 5

在这种情况下,您可以使用 Homebrew 正确安装适用于 macOS 的 PostgreSQL 客户端,然后链接它,因为它将所有工具符号链接到/usr/local/bin目录中。

要解决此问题,请运行以下命令:

$ brew services stop postgresql
$ brew install postgresql@10
$ brew services start postgresql@10
$ brew link --overwrite --force postgresql@10
Run Code Online (Sandbox Code Playgroud)

参考:https : //www.compose.com/articles/postgresql-tips-installing-the-postgresql-client/