1. 程式人生 > 資料庫 >PostgreSQL修改配置檔案實現遠端訪問(linux版)

PostgreSQL修改配置檔案實現遠端訪問(linux版)

linux版的postgresql預設無法直接遠端訪問其資料庫,需要修改postgreSQL資料庫配置來實現遠端訪問。

具體操作如下:
使用find / -name postgresql.conf找到 postgresql.conf
在最後新增使用者引數:
listen_address = ‘*’,注意不要被註釋掉

啟用密碼驗證
#password_encryption = md5 
修改為 
password_encryption = md5

修改pg_hba.conf檔案的內容:
可訪問的使用者ip段
在檔案末尾加入:host  all  all  0.0.0.0/0  md5

重啟postgreSQL資料庫:
systemctl restart postgresql-12
啟動成功後,再在遠端連線