CentOS7 PostgreSQL 安装

PostgreSQL安装

安装
使用yum安装 (找源 http://yum.postgresql.org/)

yum install https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm
yum install postgresql95-server postgresql95-contrib

yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm

yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm

初始化数据库
/usr/pgsql-9.5/bin/postgresql95-setup initdb

启动服务

systemctl start postgresql-9.5.service

systemctl status postgresql-9.5.service

设置开机启动 (centos 服务安装位置 cd /usr/lib/systemd/system/*.service)

systemctl enable postgresql-9.5.service

开启远程访问
/var/lib/pgsql/9.5/data/postgresql.conf

listen_addresses ='*'
/var/lib/pgsql/9.5/data/pg_hba.conf

# IPv4 local connections:
host all all 127.0.0.1/32 trust
host all all 192.168.117.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust


修改用户密码

su postgres
psql -U postgres
ALTER USER postgres WITH PASSWORD 'postgres'
\q

posted @ 2016-05-05 17:33  Eamon13  阅读(783)  评论(1编辑  收藏  举报