Centos通过Yum安装postgresql数据库以及postgis扩展的安装
Centos通过Yum安装postgresql数据库以及postgis扩展的安装
因为项目上的使用的是postgis来处理地理数据 ,而开发环境的数据库以及postgis扩展并不是我安装的。所以在迁移的时候造成了不小的麻烦。记录一下迁移过程中遇到的。下面以Linux(Centos7)操作系统为例。
卸载postgresql
yumremovepostgresql*
我选择直接执行这个指令暴力删除,这个会把postgresql数据库联通postgis(如果安装的话)一起删除
安装postgresql
下载postgresql13可以通过下面的命令下载,其他版本到直接去下面的官网上面下载就完事了
sudoyuminstall-yhttps://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpmsudoyuminstall-ypostgresql13-serversudo/usr/pgsql-13/bin/postgresql-13-setupinitdbsudosystemctlenablepostgresql-13sudosystemctlstartpostgresql-13
或者前往官网下载地址:https://www.postgresql.org/download/
netstat-tnlp|grep5432
如果查询结果说明数据库已经被启动
启动数据库
systemctl start postgresql-13后面的13是版本号,如果你下载的是别的版本,直接替换数字既可
停止数据库
systemctlstoppostgresql-13
重启数据库
systemctlrestartpostgresql-13
修改配置文件
接下来需要修改数据库的配置文件来
postgresql.conf
首先先找到配置文件的位置
find/-namepostgresql.conf
首先先找到配置文件的位置
find/-namepg_hba.conf
下载安装postgis扩展
首先我们在yum源里面查看可用的postgisab
yumlist|greppostgis*
然后我们执行(可以选择不同版本安装)
yuminstallpostgis33_14.x86_64
安装postgis扩展
进入postgresql执行下面语句,安装所有的postgis的驱动
setpostgis.gdal_enabled_drivers='ENABLE_ALL';CREATEEXTENSIONpostgis;--EnableTopologyCREATEEXTENSIONpostgis_topology;--EnablePostGISAdvanced3D--andothergeoprocessingalgorithms--sfcgalnotavailablewithalldistributionsCREATEEXTENSIONpostgis_sfcgal;--fuzzymatchingneededforTigerCREATEEXTENSIONfuzzystrmatch;--rulebasedstandardizerCREATEEXTENSIONaddress_standardizer;--exampleruledatasetCREATEEXTENSIONaddress_standardizer_data_us;--EnableUSTigerGeocoderCREATEEXTENSIONpostgis_tiger_geocoder;CREATEEXTENSIONpostgis_raster;
有些文章会漏了下面两个,加上就好了。
setpostgis.gdal_enabled_drivers='ENABLE_ALL';CREATEEXTENSIONpostgis;
其他操作系统的步骤差不多。
参考:
https://www.kuazhi.com/post/584011.html
https://blog.csdn.net/qq_51086532/article/details/131859163
本网站文章未经允许禁止转载,合作/权益/投稿 请联系平台管理员 Email:epebiz@outlook.com