yum install -y https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7.2-x86_64/pgdg-centos96-9.6-3.noarch.rpm
yum
install -y
postgresql96-server postgresql96-contrib
3、初始化数据库
1 | /usr/pgsql-9 .5 /bin/postgresql95-setup initdb |
4、设置开机自启动
1 | systemctl enable postgresql-9.5.service |
5、启动服务
1 | systemctl start postgresql-9.5.service |
6、查看版本
PostgreSQL 9.5安装配置
1、修改用户密码
1 2 3 4 | su - postgres psql -U postgres ALTER USER postgres WITH PASSWORD '123456' \q |
2、开启远程访问
1 2 | vi /var/lib/pgsql/9 .5 /data/postgresql .conf 修改 #listen_addresses = 'localhost' 为 listen_addresses='*' |
3、信任远程连接
1 | vi /var/lib/pgsql/9 .5 /data/pg_hba .conf |
1 2 3 4 | 修改如下内容,信任指定服务器连接 # IPv4 local connections: host all all 127.0.0.1 /32 ident host all all 192.168.137.1 /32 (需要连接的服务器IP) trust |
4、重启服务
1 | systemctl restart postgresql-9.5.service |