我正在尝试使用本地机器上的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.
本地Postgres版本:12.1,Azure Postgres数据库版本:10,macOS Mojave。
在重新使用Homebrew安装Postgres之后,这个问题最近才开始出现。我运行$ psql --host=localhost
没有问题。
我尝试使用Homebrew安装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
我现在可以如预期地访问 Azure 数据库。