仅做记录用
-----------------------------------------------------
1.环境准备
Centos7.4虚拟机,内存2G
卸载firewalld,关闭selinux
2.配置安装源
下载地址:https://yum.postgresql.org/repopackages.php
找到对应的系统版本,下载并rpm安装
3.安装PostgreSQL
yum -y install postgresql-server postgresql-contrib
4.初始化数据库
/usr/bin/postgresql-setup initdb
5.启动
systemctl start postgresql.service
6.修改初始密码
[root@postgres locale]# su - postgres
-bash-4.2$ psql -U postgres
alter USER postgres with encrypted password '123456';
postgres=# \q
-bash-4.2$ exit
7.配置远程访问
vim /var/lib/pgsql/data/postgresql.conf
将listen_address 改为*并去掉注释
vim /var/lib/pgsql/data/pg_hba.conf
在底部添加一行
host all all 0.0.0.0/0 md5
8.重启服务,检查端口
对于用户Ident认证失败,在 /var/lib/pgsql/data/pg_hba.conf中将METHOD修改为md5或者trust