如何在macOS中为postgresql@13创建PostGIS符号链接?
解决PostGIS与postgresql@13的链接问题
方案一:重新安装适配postgresql@13的PostGIS版本(推荐)
这是最稳妥的方法,确保PostGIS完全适配你的postgresql@13:
- 停止所有PostgreSQL服务:
brew services stop postgresql@13 brew services stop postgresql@14 - 卸载当前的PostGIS:
brew uninstall postgis - 将postgresql@13设为brew默认的PostgreSQL版本:
brew link postgresql@13 --force - 重新安装PostGIS,brew会自动编译适配postgresql@13的版本:
brew install postgis - 启动postgresql@13服务:
brew services start postgresql@13 - 再次进入psql执行
CREATE EXTENSION postgis;即可成功。
方案二:手动创建软链接(快速临时解决)
如果不想重新安装,可以手动将PostGIS的扩展文件链接到postgresql@13的目录:
- 确认PostGIS扩展文件的位置(默认在postgresql@14的目录下),执行链接:
mkdir -p /opt/homebrew/opt/postgresql@13/share/postgresql@13/extension/ ln -s /opt/homebrew/opt/postgresql@14/share/postgresql@14/extension/postgis* /opt/homebrew/opt/postgresql@13/share/postgresql@13/extension/ - 重启postgresql@13服务:
brew services restart postgresql@13 - 进入psql执行
CREATE EXTENSION postgis;即可。
注意:手动链接可能存在版本兼容性隐患,若后续出现异常,建议切换到方案一重新安装。
内容的提问来源于stack exchange,提问作者0x55b1E06FF
相关产品推荐
相关产品推荐

