分享

Centos7安装PostgresSQL13

 HUC王子 2022-03-30

Centos7安装PostgresSQL

  • 更新系统

sudo yum update -y
  • 添加PostgreSQL Yum存储库

sudo yum install -y https://download./pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
  • 安装PostgreSQL Server和客户端软件包

sudo yum install -y postgresql13-server postgresql13
  • 查看安裝是否完成

sudo rpm -qi postgresql13-server

image-20210114133718074

  • 初始化数据库

sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
sudo systemctl enable postgresql-13
sudo systemctl start postgresql-13
# 停止数据库
sudo systemctl stop postgresql-13
  • 数据库初始化完成后,可以通过修改数据文件目录的postgresql.conf配置文件来达到设置postgresql侦听端口的目的

vim /var/lib/pgsql/13/data/postgresql.conf

listen_addresses = '*'
  • 允许远程访问

vim /var/lib/pgsql/13/data/pg_hba.conf

主要就是在ip4下加
# IPv4 local connections:
host    all             all             0.0.0.0/0            	trust

修改postgres密码

su postgres 

psql 

alter user postgres with password 'postgres';
  • 修改用户密码

  #登陆postgresql
  sudo -u postgres psql
  
  #修改i登陆postgresql密码
  alter user postgres with password 'postgres';
  • 开放防火墙

firewall-cmd --zone=public --add-port=5432/tcp --permanent
firewall-cmd --reload
# 查看是否开放
firewall-cmd --query-port=5432/tcp

安装PostGIS

  • 将EPEL存储库添加到CentOS 7

EPEL存储库中有许多依赖项,运行以下命令在CentOS 7计算机中安装epel存储库:

sudo yum -y install epel-release
  • 安装PostGIS

sudo yum -y install postgis31_13

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多