[英]How can I connect to Postgres running in a Docker container on a non-default port from the command line?
[英]Specifying non-default port for Homebrew Postgres server
我在 macOS 上使用 Homebrew 安裝了 Postgres。 我可以使用命令brew services start postgres
啟動一個偵聽默認端口 5432 的 Postgres 服務器,但我希望它使用不同的端口。
使用我的 Homebrew Postgres 安裝,我如何啟動一個偵聽另一個端口的 Postgres 服務器?
對於持久修復,您可以更改配置文件:
1.確定brew在哪里安裝了Postgres
brew info postgresql@<your_version>
我機器上的位置是/usr/local/opt/postgresql@14/share/postgresql@14
2.導航到那里並打開postgresql.conf
#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------
# - Connection Settings -
listen_addresses = 'localhost' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5555 # (change requires restart)
然后您可以在重新啟動 postgresql 之前設置端口和地址。
3.重啟postgresql
brew services restart postgresql
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.