# centos 6.8 安装 # 见官网 :https://www.postgresql.org/download/linux/redhat/ # 选择对应信息后。 yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/pgdg-centos96-9.6-3.noarch.rpm yum install postgresql96 yum install postgresql96-server # 初始化 service postgresql-9.6 initdb chkconfig postgresql-9.6 on service postgresql-9.6 start
# 查看 数据目录 cat /etc/rc.d/init.d/postgresql-9.6 | grep -n PGDATA -n # 远程可连接 vi /var/lib/pgsql/9.6/data/postgresql.conf # 59行 listen_addresses = '*' # vi /var/lib/pgsql/9.6/data/pg_hba.conf # 按照要求配置,笔者修改的是注释82行,增加了一行:83行 77 # TYPE DATABASE USER ADDRESS METHOD 78 79 # "local" is for Unix domain socket connections only 80 local all all peer 81 # IPv4 local connections: 82 #host all all 127.0.0.1/32 ident 83 host all all 192.168.1.0/24 md5 84 # IPv6 local connections: 85 host all all ::1/128 ident 86 # Allow replication connections from localhost,by a user with the
su postgres //切换用户 psql -U postgres // 进入交互式 # 修改密码 alter user postgres with password '1234';
重启后,使用pgAdmin 即可远程连接。
原文链接:https://www.f2er.com/postgresql/193398.html