服务器连接到Azure Postgres时意外关闭连接 [英] Server closes connection unexpectedly when connecting to Azure Postgres
问题描述
我正在尝试从本地计算机使用psql连接到Azure Postgresql,并出现以下错误:
I'm trying to connect to Azure Postgresql using psql from my local machine and get the following error:
$ 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.
本地Postgres版本:12.1,Azure Postgres数据库版本:10,macOS Majove。
Local Postgres version: 12.1, Azure Postgres database version: 10, macOS Majove.
这个问题仅在我使用Homebrew重新安装Postgres之后才开始。我在运行 $ psql --host = localhost
时没有问题。
This issue only recently started after I reinstalled Postgres using Homebrew. I have no issues running $ psql --host=localhost
.
我尝试通过自制软件安装 postgresql @ 10
,以便在运行 psql时
我收到消息 psql(12.1,服务器10.11)
。但是,当我尝试登录到Azure Postgres时,出现与上述相同的错误。
I've tried installing postgresql@10
with homebrew so that when I run psql
I get the message psql (12.1, server 10.11)
. But when I attempt to log into Azure Postgres I get the same error as above.
我对Postgres和Azure还是很陌生,希望您能提出任何建议。
I'm fairly new to Postgres and Azure and would appreciate any suggestions.
更新:
感谢您的评论和反馈。
Thanks for the comments and feedback.
我用Homebrew正确安装了Postgres 10,并链接了它以解决问题。
I properly installed Postgres 10 with Homebrew and linked it to fix the problem.
$ brew services stop postgresql
$ brew install postgresql@10
$ brew services start postgresql@10
$ brew link --overwrite --force postgresql@10
<现在,我可以按预期访问Azure数据库了。
I can now access the Azure database as expected.
推荐答案
在这种情况下,您可以使用Homebrew正确安装macOS的PostgreSQL客户端,然后将其链接,因为它将符号链接所有工具进入 / usr / local / bin
目录。
In this case, you could install the PostgreSQL Client for macOS with Homebrew properly then link it as it will symlink all the tools into the /usr/local/bin
directory.
要解决此问题,请运行以下命令:
To fix this issue, run the following commands:
$ brew services stop postgresql
$ brew install postgresql@10
$ brew services start postgresql@10
$ brew link --overwrite --force postgresql@10
参考: https://www.compose.com/articles/postgresql-tips-installing- -postgresql-client /
这篇关于服务器连接到Azure Postgres时意外关闭连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!