我已经通过 Homebrew 安装了 Postgresql@9.6 和 Postgis。但是,通过 Homebrew 安装 Postgis 会在 10 作为依赖项安装最新版本的 Postgresql,并将 Postgresql 固定在 9.6.5 会阻止通过 Homebrew 安装 Postgis。
执行“CREATE EXTENSION postgis;”返回:
错误:无法打开扩展控制文件“/usr/local/Cellar/postgresql@9.6/9.6.5/share/postgresql@9.6/extension/postgis.control”:没有这样的文件或目录
我还尝试卸载 Postgresql(在 10)并编辑 Postgis 公式以依赖 Postgres@9.6 而不是 Postgresql。
这类似于 How to install Postgis to a Keg installation of Postgres@9.5 using Homebrew?但后来有了小桶配方
最佳答案
经过多次组合,我设法做到了。
简而言之,解决方案是安装旧版本的原始包postgres
,切换到它,并安装旧版本的postgis
。
安装postgres
1/安装当前版本的postgres
(10.1为准)
brew install postgres
2/使用旧的公式安装旧版本的 postgres。可以使用 github 找到正确的链接或 Tap 存储库 (/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/
) 上的 git log
。
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/d014fa223f77bee4b4097c5e80faa0954e28182f/Formula/postgresql.rb
这将安装版本 9.6.5(10.x 系列之前的最后一个版本)。
3/切换到它以便链接默认为 postgres 9.6
brew switch postgres 9.6.5
安装postgis
4/安装旧版本的 postgis (2.3)。这是使用相同的 sha 版本的公式,因此所有内容都正确链接(使用当前的 postgis 将期望 postgresql 10,因此在初始化扩展时最终会导致版本不匹配)。
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/d014fa223f77bee4b4097c5e80faa0954e28182f/Formula/postgis.rb
使用它们
5/如果需要初始化数据库
initdb /usr/local/var/postgres
6/创建和使用你的数据库
createdb mydb
psql mydb
mydb=# CREATE EXTENSION postgis;
关于postgresql - 如何使用 Homebrew 将 Postgis 安装到 Postgres@9.6 的 Keg 安装中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47079305/