系統(tǒng)環(huán)境說(shuō)明:
??[root@slave1 ~]# cat /etc/redhat-release
??CentOS Linux release 7.4.1708 (Core)
開(kāi)始
??1尾组、Postgresql12的安裝
????https://www.postgresql.org/download/linux/redhat/
1享钞、下載安裝
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum install postgresql12
yum install postgresql12-server
yum install postgresql12-libs
yum install postgresql12-contrib
yum install postgresql12-devel
2蝶缀、數(shù)據(jù)庫(kù)初始化與設(shè)置自啟動(dòng)
/usr/pgsql-12/bin/postgresql-12-setup initdb
systemctl enable postgresql-12
systemctl start postgresql-12
3题造、編輯遠(yuǎn)程訪問(wèn)
cd /var/lib/pgsql/12/data
vi postgresql.conf
修改前:
#listen_address = ‘localhost’
i進(jìn)入械哟,下移光標(biāo)
修改為 listen_address = ‘*’ 注意:這里將#去掉
Esc退出編輯模式,shift和:鍵,輸入wq進(jìn)行保存并退出,q表示只退出不保存
vi pg_hba.conf
添加IPv4
host all all 0.0.0.0/32 md5
4闪檬、重新啟動(dòng)服務(wù)
systemctl restart postgresql-12
退出當(dāng)前文件回到根目錄
cd /
5、登錄數(shù)據(jù)庫(kù)
su postgres
psql –U postgres
\password //修改密碼
\q 退出postgres命令
6购笆、卸載
yum remove postgresql*
??2粗悯、Postgis的安裝
yum install postgis30_12
新建庫(kù),添加postgis擴(kuò)展
create extension postgis; //sql語(yǔ)句必須以;結(jié)尾
\q退出postgres命令
Logout或者exit退出bash
新建用戶
create user map_tz with password 'dl123';
新建庫(kù)
create database dl owner map_tz;
賦權(quán)限
grant all privileges on database dl to map_tz;
添加postgis擴(kuò)展
create extension postgis;
create extension postgis_topology;
最后
??結(jié)果如圖