Linux yum安装PostgreSQL9.6

Linux yum安装PostgreSQL9.6

PostgreSQL10版本的主从安装配置在 http://www.javashuo.com/article/p-xugkknvh-ee.htmlhtml

1、下载安装

一、建立PostgreSQL9.6的yum源文件

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

二、安装PostgreSQL客户端

$ yum install postgresql96

三、安装PostgreSQL服务端

$ yum install postgresql96-server

四、安装PostgreSQL拓展包(可选)

$ yum install postgresql96-devel.x86_64

五、安装PostgreSQL的附加模块(可选)

$ yum install postgresql96-contrib.x86_64

2、配置初始化

初始化数据库

$ /usr/pgsql-9.6/bin/postgresql96-setup initdb

启动postgresql服务,并设置为开机自动启动

$ systemctl enable postgresql-9.6
$ systemctl start postgresql-9.6

postgres用户初始配置

安装完成后,操做系统会自动建立一个postgres用户用来管理数据库,为其初始化密码(输入命令后连输2次密码):

$ passwd postgres

数据库初始配置

使用数据库自带的postgres用户登陆数据库,并为其赋予密码

$ su - postgres
$ psql -U postgres
alter user postgres with password '你的密码';

配置远程链接

可能在/var/lib/pgsql/9.6/data下,能够linux

一、使用find / -name 'pg_hba.conf'查找到pg_hba.conf,修改pg_hba.conf

在最后添加容许访问IP段(全网段可访问)
host all all 0.0.0.0/0 md5sql

二、使用find / -name 'postgresql.conf'找到 postgresql.conf

找到用户参数listen_address(取消掉注释),改为下面样式:数据库

listen_address = '*'

启用密码验证centos

#password_encryption = on 修改成 password_encryption = on

三、重启数据库

$ systemctl restart postgresql-9.6

备注:使用Navicat For PostgreSql来链接post

相关文章
相关标签/搜索