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