centos 上安装 postgresql 9.5

1.安装 yum 源

sudo yum install http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm

(从 http://yum.postgresql.org/repopackages.php 获取该地址)

2.安装 postgresql95-server 和 postgresql95-contrib

sudo yum install postgresql95-server postgresql95-contrib

安装后,可执行文件在 /usr/pgsql-9.5/bin/, 数据和配置文件在 /var/lib/pgsql/9.5/data/

3.初始化数据:

sudo /usr/pgsql-9.5/bin/postgresql95-setup initdb

4.不支持密码认证,修改 pg_hab.conf 将 ident 替换为 md5 (可选)

sudo vim /var/lib/pgsql/9.5/data/pg_hba.conf

5.启动服务:

sudo systemctl start postgresql-9.5.service

6.修改用户密码

sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"

7.配置远程访问

vi /var/lib/pgsql/9.5/data/postgresql.conf

修改#listen_addresses = ‘localhost’ 为 listen_addresses=’‘,此处‘’也可以是指定的服务器IP

vi  /var/lib/pgsql/9.5/data/pg_hba.conf

修改如下内容,加入一行:

# IPv4 local connections:
host    all             all         0.0.0.0/0               md5

修改配置后需要重启:

systemctl restart postgresql-9.5.service

如果还是连接不通,可能需要打开防火墙,配置完成后可以用Navicat for Postgresql连接数据库,其操作跟MysqL一样。

设置为开机启动:

sudo systemctl enable postgresql-9.5.service

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native
centos6.5下postgres-XC集群安装与配置
CentOS 6使用openssl搭建根CA
CentOS6.6中安装VNC server
CentOS下更新Python最新版本
Centos安装pycurl
CentOS 7 安装PostGIS
CentOS 7.1PXE网络自动化安装
CentOS下ffmpeg与第三方编码编译安装
CentOS 6.4安装配置squid
CentOS6.5 安装配置drbd
CentOS6.4 安装jenkins
centos安装增强工具
CentOS6.4安装配置redis
CentOS 6上部署OpenVPN Server