因為項目上的使用的是postgis來處理地理數(shù)據(jù) ,而開發(fā)環(huán)境的數(shù)據(jù)庫以及postgis擴展并不是我安裝的。所以在遷移的時候造成了不小的麻煩。記錄一下遷移過程中遇到的。下面以Linux(Centos7)操作系統(tǒng)為例。
卸載postgresql
yum remove postgresql*
我選擇直接執(zhí)行這個指令暴力刪除,這個會把postgresql數(shù)據(jù)庫聯(lián)通postgis(如果安裝的話)一起刪除
安裝postgresql
下載postgresql13可以通過下面的命令下載,其他版本到直接去下面的官網(wǎng)上面下載就完事了
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm sudo yum install -y postgresql13-server sudo /usr/pgsql-13/bin/postgresql-13-setup initdb sudo systemctl enable postgresql-13 sudo systemctl start postgresql-13
或者前往官網(wǎng)下載地址:https://www.postgresql.org/download/
netstat -tnlp | grep 5432
如果查詢結(jié)果說明數(shù)據(jù)庫已經(jīng)被啟動
啟動數(shù)據(jù)庫
systemctl start postgresql-13后面的13是版本號,如果你下載的是別的版本,直接替換數(shù)字既可
停止數(shù)據(jù)庫
systemctl stop postgresql-13
重啟數(shù)據(jù)庫
systemctl restart postgresql-13
修改配置文件
接下來需要修改數(shù)據(jù)庫的配置文件來
postgresql.conf
首先先找到配置文件的位置
find / -name postgresql.conf
首先先找到配置文件的位置
find / -name pg_hba.conf
下載安裝postgis擴展
首先我們在yum源里面查看可用的postgisab
yum list | grep postgis*
然后我們執(zhí)行(可以選擇不同版本安裝)
yum install postgis33_14.x86_64
安裝postgis擴展
進入postgresql執(zhí)行下面語句,安裝所有的postgis的驅(qū)動
set postgis.gdal_enabled_drivers ='ENABLE_ALL'; CREATE EXTENSION postgis; -- Enable Topology CREATE EXTENSION postgis_topology; -- Enable PostGIS Advanced 3D-- and other geoprocessing algorithms -- sfcgal not available with all distributions CREATE EXTENSION postgis_sfcgal; -- fuzzy matching needed for Tiger CREATE EXTENSION fuzzystrmatch; -- rule based standardizer CREATE EXTENSION address_standardizer; -- example rule data set CREATE EXTENSION address_standardizer_data_us; -- Enable US Tiger Geocoder CREATE EXTENSION postgis_tiger_geocoder; CREATE EXTENSION postgis_raster;
有些文章會漏了下面兩個,加上就好了。
set postgis.gdal_enabled_drivers ='ENABLE_ALL'; CREATE EXTENSION postgis;
其他操作系統(tǒng)的步驟差不多。
參考:
https://www.kuazhi.com/post/584011.html
https://blog.csdn.net/qq_51086532/article/details/131859163
本文內(nèi)容根據(jù)網(wǎng)絡(luò)資料整理,出于傳遞更多信息之目的,不代表金鑰匙跨境贊同其觀點和立場。
轉(zhuǎn)載請注明,如有侵權(quán),聯(lián)系刪除。