PostgreSQL 是一套十分出名的關聯式資料庫系統, CentOS 預設的 Repository 已經包含了 PostgreSQL, 所以可以很簡單地用 YUM 安裝,以下是在 RHEL 及 CentOS 7 透過 YUM 安裝 PostgreSQL 的步驟:
# yum install postgresql-server postgresql-contrib -y
安裝好 PostgreSQL 後, 執行以下指令初始化安裝:
# postgresql-setup initdb
開啟 /var/lib/pgsql/data/pg_hba.conf 修改設定:
在接近最底部的位置, 找到類似以下兩行:
1 2 |
host all all 127.0.0.1/32 ident host all all ::1/128 ident |
將 ident 改成 “md5”, 即改成這樣:
1 2 |
host all all 127.0.0.1/32 md5 host all all ::1/128 md5 |
現在可以啟動 PostgreSQL 及設定開機自動執行:
# systemctl start postgresql
# systemctl enable postgresql
# systemctl enable postgresql