CentOS阿里云linux服务器安装PostgreSQL 11和PostGIS 3并用Postgres pgAdmin连接记录

1. 检查PostgreSQL 是否已经安装

[root@TS-DEV ~]# rpm -qa|grep postgres
[root@TS-DEV ~]# 

若已经安装,则使用rpm -e 包名 命令卸载,卸载时只需要包名即可。

2、CentOS阿里云linux服务器安装参考: https://developer.aliyun.com/article/750153 (注意:yum update -y慎用)
下载postgresql软件Linux版本安装参考:https://www.cnblogs.com/freeweb/p/8006639.html
3、修改PostgreSQL数据库默认用户postgres的密码。PostgreSQL数据库创建一个postgres用户作为数据库的管理员,密码随机,所以需要修改密码,方式如下:
(1)登录PostgreSQL

sudo -u postgres psql

(2)修改登录PostgreSQL密码

ALTER USER postgres WITH PASSWORD 'postgres';

注:密码postgres要用引号引起来命令最后有分号
(3)退出PostgreSQL客户端

\q

退出回到顶部

4. 修改linux系统postgres用户的密码
PostgreSQL会创建一个默认的linux用户postgres,修改该用户密码的方法如下:
(1)删除用户postgres的密码

sudo  passwd -d postgres

(2)设置用户postgres的密码

sudo -u postgres passwd

系统提示输入新的密码

Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

5、Postgres pgAdmin连接PostgreSQL 数据库报错:no pg_hba.conf entry for host
解决办法:在PostgreSQL数据库的安装目录下找到/data/pg_hba.conf,找到“# IPv4 local connections:”在其下加上0.0.0.0/0或请求连接的机器IP例如10.1.1.5/32,如下所示:

host all all 0.0.0.0/0 md5
host all all 10.1.1.5/32 md5

0.0.0.0/0表示允许任何用户连接到任何数据库,32是子网掩码的网段;md5是密码验证方法
备注:修改pg_hba.conf后重启服务生效,重启服务命令如下:
#启动,停止,重启服务
systemctl start  postgresql-11.service
systemctl stop postgresql-11.service
systemctl restart postgresql-11.service
#查看一个服务的状态
systemctl status postgresql-11.service
#开机时启用一个服务
systemctl enable postgresql-11.service
#开机时关闭一个服务
systemctl disable postgresql-11.service
#查看服务是否开机启动
systemctl is-enabled postgresql-11.service

6、Postgres pgAdmin连接问题: Unable to connect to server: timeout expired
问题描述:超时已过期pgadmin无法连接到服务器(Timeout expired pgadmin Unable to connect to server)
解决办法:
(1)修改pg_hba.conf文件内容如下:

host    all             all             <your_ip/mask>          ident

为:

host    all             all             <your_ip/mask>          md5

注意,其中<your_ip/mask>为IP地址. 例如10.1.1.5/32
备注:修改pg_hba.conf后重启服务生效,重启服务命令参考5中备注
(2)如果还不行,试试开放防火墙
输入firewall-cmd --add-service=postgresql --permanent并回车,开放防火墙
输入firewall-cmd --reload并回车,重启防火墙

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值