版本: PostgreSQL14
今天剛入手這個資料庫玩玩,發現無法通過IP去訪問資料庫,
後面查詢原因為,該資料庫預設只能通過本地連線,也就是迴環地址(127.0.0.1)
該檔案位於初始化安裝的資料庫目錄下
編輯** pg_hba.conf** 組態檔

# TYPE  DATABASE        USER            ADDRESS                 METHOD
# "local" is for Unix domain socket connections only
local   all             all                                     scram-sha-256
# IPv4 local connections:
host    all             all             127.0.0.1/32            scram-sha-256
host    all             all             0.0.0.0/0        trust
host    all             all             0.0.0.0/0        md5
host    all             all             127.0.0.1/32            md5
host    all             all             localhost        trust
# 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
host    all             all             ::0/0        md5
參考來源: https://docs.postgresql.tw/server-administration/client-authentication/the-pg_hba.conf-file