centos73postgresql9.6.2rpm安装

postgresql9.6.2 rpm 安装

我们提供的服务有:网站建设、网站制作、微信公众号开发、网站优化、网站认证、武冈ssl等。为成百上千企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的武冈网站制作公司

1、安装rpm包

rpm -ivf postgresql96-libs-9.6.2-2PGDG.rhel7.x86_64.rpm 

rpm -ivf postgresql96-9.6.2-2PGDG.rhel7.x86_64.rpm 

rpm -ivf postgresql96-server-9.6.2-2PGDG.rhel7.x86_64.rpm 

rpm -ivf postgresql96-contrib-9.6.2-2PGDG.rhel7.x86_64.rpm

rpm -ivf postgresql96-devel-9.6.2-2PGDG.rhel7.x86_64.rpm

2、初始化PostgreSQL 数据库

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

3、启动服务

systemctl start postgresql-9.6.service

4、把PostgreSQL 服务加入到启动列表

systemctl enable postgresql-9.6.service

5、修改PostgreSQL 数据库用户postgres的密码(注意不是linux系统帐号)

PostgreSQL 数据库默认会创建一个postgres的数据库用户作为数据库的管理员,默认密码为空,我们需要修改为指定的密码,这里设定为’postgres’。

# su - postgres 切换用户,执行后提示符会变为 '-bash-4.2$'

  

$  psql 登录数据库,执行后提示符变为 'postgres=#'

  

postgres=# alter user postgres with password 'postgres';

ALTER ROLE

postgres=# select * from pg_shadow;

6、测试数据库

6.1 创建测试数据库

postgres=# create database test;

6.2、切换到david 数据库

# \c test

6.3、创建测试表

test=# create table t1 (id integer, name text);

6.4、插入测试数据

test=# insert into t1 values (1,'t1');

INSERT 0 1

test=# 

6.5、选择数据

test=# select * from t1 ;

 id | name  

----+-------

  1 | t1

(1 row)

test=#

测试完成,RPM包安装成功。

7、修改linux 系统用户postgres 的密码

PostgreSQL 数据库默认会创建一个linux 系统用户postgres,通过passwd 命令设置系统用户的密码为postgres。

# passwd postgres

8、修改PostgresSQL 数据库配置实现远程访问

8.1 修改postgresql.conf 文件

# vim /var/lib/pgsql/9.6/data/postgresql.conf

如果想让PostgreSQL 监听整个网络的话,将listen_addresses 前的#去掉,并将 listen_addresses = 'localhost' 改成 listen_addresses = '*'

8.2 修改客户端认证配置文件pg_hba.conf

将需要远程访问数据库的IP地址或地址段加入该文件。

# vim /var/lib/pgsql/9.6/data/pg_hba.conf

在“# IPv4 local connections”添加

host    all             all             127.0.0.1/32            ident

host    all             all             192.168.1.199/24        md5

9. 重启服务以使设置生效

# systemctl restart postgresql-9.6.service

10、远程测试可以使用客户端工具或者装有postgresql的机器,通过cmd访问

psql -U postgres -h 192.168.1.199

问题:

1)、配置支持远程连接

$ vim /var/lib/pgsql/9.6/data/pg_hba.conf

#### 直接配置为不限制IP,即0.0.0.0,注意:/后面也必须为0!!! ####

将 127.0.0.1/32 改为 0.0.0.0/0

顺便将该行method属性的ident修改为trust,不然用客户端工具远程连接的时候会报用户postgres ident认证失败的错误。

2)、去除版本号启动服务

cd /usr/lib/systemd/system

ln -s postgresql-9.6.service postgresql.service

以后就可以使用

systemctl start postgresql

文章名称:centos73postgresql9.6.2rpm安装
链接分享:https://www.cdcxhl.com/article46/jgsgeg.html

成都网站建设公司_创新互联,为您提供微信小程序品牌网站制作小程序开发网站排名手机网站建设移动网站建设

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都网站建设公司