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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM