簡體   English   中英

如何連接到同一網絡上但在不同計算機上運行的 PSQL 數據庫

[英]How to connect to a PSQL database on the same network but running on a different computer

我嘗試了很多東西,到目前為止我的理解是讓 psql 服務器(計算機 1)偵聽將要連接到它的另一台計算機(計算機 2)。 我打開了我的 pg_hba 配置文件:

# "local" is for Unix domain socket connections only
local   all             all                                     scram-sha-256
# IPv4 local connections:
host    all             all             127.0.0.5/32            scram-sha-256
# IPv6 local connections:
host    all             all             ::1/128                 scram-sha-256
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     scram-sha-256
host    replication     all             127.0.0.1/32            scram-sha-256
host    replication     all             ::1/128                 scram-sha-256

到目前為止,它似乎正在偵聽本地網絡上運行的所有服務器。

當我嘗試使用 CMD 從計算機 2 連接時

psql -h 127.0.0.5 -U postgres;

系統提示我輸入密碼,但我連接的數據庫是在計算機 2 上運行的數據庫,而不是在計算機 1 上運行的數據庫

我可以在這里做什么? 感謝您閱讀到目前為止。

  1. psql是 Postgres 客戶端的名稱。 當提到服務器時,請使用 Postgres 或 Postgresql。
  2. pg_hba.conf 用於客戶端身份驗證,而不是設置服務器正在偵聽的地址。
  3. 你顯示的 pg_hba.conf 的內容表明服務器將只接受從同一台機器連接的客戶端。
  4. 您正在尋找的設置在 postgresql.conf 中作為listen_addresses
  5. 閱讀此pg_hba.conf以獲取有關如何設置它的更多信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM