Clone
4
5.1 PostgreSQL
jsc-wiki edited this page 2026-10-14 06:27:29 +00:00

PostgreSQL

第5章 資料庫與搜尋 · 來源:JSC 知識庫

簡介

PostgreSQL 是常用的開源關聯式資料庫。本文記錄在 Ubuntu 上安裝 PostgreSQL,並開放特定主機與使用者外部連線的步驟。

步驟

1. 安裝 PostgreSQL

apt update && apt install -y postgresql

2. 允許外部連線

編輯用戶端認證設定檔 pg_hba.conf(路徑中的 17 為 PostgreSQL 主版本號,請依實際版本調整)。

nano /etc/postgresql/17/main/pg_hba.conf

加入下列規則,允許來自 192.168.230.221 網段的 gitea 使用者,以 md5 密碼驗證存取 gitea 資料庫。

...
host    gitea           gitea           192.168.230.221/24      md5

注意:另需確認 postgresql.conf 的 listen_addresses 已開放對應介面(例如設為 '*'),外部連線才會生效。

3. 重啟服務

讓設定生效並檢視狀態。

systemctl restart postgresql && systemctl status postgresql

← 第5章 資料庫與搜尋 · 本章目錄 · 全書目錄 · 5.2 SQLServer →