首页 > 数据库技术 > 详细

centos7上的postgresql10安装和配置

时间:2018-07-15 22:36:41      阅读:265      评论:0      收藏:0      [点我收藏+]

安装数据库

安装参考官方文档:https://www.postgresql.org/download/linux/redhat/

1.Install the repository RPM:
yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm
2.Install the client packages:安装client工具
yum install postgresql10
3.Optionally install the server packages:安装服务端
yum install postgresql10-server
4.Optionally initialize the database and enable automatic start:初始化数据库并启动pgsql
/usr/pgsql-10/bin/postgresql-10-setup initdb
systemctl enable postgresql-10
systemctl start postgresql-10

调整数据库配置

数据文件目录:

[root@fkkfapp data]# pwd
/var/lib/pgsql/10/data

修改数据库监听端口,开放所有ip监听,增加所有 ipv4地址接入权限
1.修改postgresql.conf文件


[root@fkkfapp data]# vi /var/lib/pgsql/10/data/postgresql.conf 

修改以下部分:

listen_addresses = '*'       
port = 1521                          

我因为外网代理端口的原因所以修改为1521,正常不需要修改

2.修改pg_hba.conf文件

[root@fkkfapp data]# vi /var/lib/pgsql/10/data/pg_hba.conf 

新增第三行信息

# IPv4 local connections:
host    all             all             127.0.0.1/32            ident
host    all             all             0.0.0.0/0               trust

3.修改/etc/profile文件,增加PGPORT设置

vi /etc/profile
export PGPORT=1521

4.切换到postgres用户,测试是否可以连接

-bash-4.2$ psql
psql (10.4)
Type "help" for help.

postgres=# 

5.使用外网navicat测试,可以登录远程端口

新建用户和数据库

postgres=# create user panda with password 'panda';

postgres=# create database panda owner panda;

postgres=# grant all privileges on database panda to panda;

centos7上的postgresql10安装和配置

原文:https://www.cnblogs.com/mousezhou/p/9314935.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!