CentOS7安装postgreSQL11

官网安装方法:

https://www.postgresql.org/download/linux/redhat/

1.添加PostgreSQL Yum存储库

yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm

2.安装PostgreSQL Server和客户端软件包

yum -y install postgresql11-server postgresql11

安装postgis

安装postgis工具包

yum install wget net-tools epel-release -y
yum install postgis30_11

3.初始化数据库并启用自动启动

# 初始化
/usr/pgsql-11/bin/postgresql-11-setup initdb 
# 启动
systemctl start postgresql-11
# 设置开机自启动
systemctl enable postgresql-11

4.启用远程访问PostgreSQL(作用是可以通过公网连接你的数据库,前提是你有公网ip)

# 我的路径是这样的
vi /var/lib/pgsql/11/data/postgresql.conf
# 修改
listen_addresses = '*'
# 我的路径是这样的
vi /var/lib/pgsql/11/data/pg_hba.conf
# 修改
host    all             all             127.0.0.1/32            md5
# 添加
host    all             all             0.0.0.0/0                trust
# 重启
systemctl restart postgresql-11

5.设置PostgreSQL管理员用户的密码(一定要按照这种格式配置用户名和密码)

su - postgres
psql -c "alter user 用户名 with password '密码'"

 安装postgis扩展

CREATE EXTENSION postgis;

6.御载postgres

yum 删除软件包:
yum remove postgresql*
删除相关目录文件:
rm -rf  /var/lib/pgsql
rm -rf  /usr/pgsql*
删除pg相关用户组/用户
userdel -r postgres
groupdel postgres
原文地址:https://www.cnblogs.com/xiaofengfree/p/13552177.html