postgresql 创建 Postgis 扩展:“错误:无法打开扩展控制文件”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44851761/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Creating Postgis extension: "ERROR: could not open extension control file"
提问by Fiona
I am getting the following error when I run create extension postgis;
运行时出现以下错误 create extension postgis;
ERROR: could not open extension control file "/Library/PostgreSQL/9.6/share/postgresql/extension/postgis.control": No such file or directory
ERROR: could not open extension control file "/Library/PostgreSQL/9.6/share/postgresql/extension/postgis.control": No such file or directory
I am using Postgres 9.6.3 and PostGIS 2.3.2 installed using Homebrew on OS X El Capitan.
我在 OS X El Capitan 上使用 Homebrew 安装了 Postgres 9.6.3 和 PostGIS 2.3.2。
mdfind -name postgis.control
shows:
mdfind -name postgis.control
显示:
/usr/local/Cellar/postgis/2.3.2/share/postgresql/extension/postgis.control
/usr/local/Cellar/postgis/2.3.2/share/postgresql/extension/postgis.control
brew info postgis
shows:
brew info postgis
显示:
PostGIS extension modules installed to:
/usr/local/share/postgresql/extension
When I start the Postgres console I see:
当我启动 Postgres 控制台时,我看到:
psql (9.6.3, server 9.6.1)
I read a similar question, PostGIS Homebrew installation referencing an old path?, and tried to reload postgresql using the commands given in the top answer, but I am still seeing psql (9.6.3, server 9.6.1)
. Also, I believe my issue is different because it's looking for the extension control file in /Library
and not /usr/local/Cellar
.
我读了一个类似的问题,PostGIS Homebrew 安装引用旧路径?,并尝试使用顶级答案中给出的命令重新加载 postgresql,但我仍然看到psql (9.6.3, server 9.6.1)
. 另外,我相信我的问题是不同的,因为它正在寻找扩展控制文件/Library
而不是/usr/local/Cellar
.
Any help would be appreciated.
任何帮助,将不胜感激。
回答by abby37
When you try to install postgis it install latest version of postgresql along with it as dependency. So if you installed postgres@V (where V is user desired version )
当您尝试安装 postgis 时,它会安装最新版本的 postgresql 作为依赖项。因此,如果您安装了 postgres@V(其中 V 是用户所需的版本)
brew install postgresql@V
brew install postgresql@V
later you run this command
稍后你运行这个命令
brew install postgis
brew install postgis
it will install postgres10.1 or whatever is latest. So after that if run
它将安装 postgres10.1 或任何最新的。所以在那之后如果运行
create extension postgis;
create extension postgis;
In postgresql@V it will try to check its extension directory and it won't find postgis.control in extension directory as this postgis is installed in extension folder of postgresql version that is installed with that.
在 postgresql@V 中,它会尝试检查它的扩展目录,但它不会在扩展目录中找到 postgis.control,因为这个 postgis 安装在与它一起安装的 postgresql 版本的扩展文件夹中。
To solve this problem, you have to create a symlink from given installation of postgis to the desired postgresql@V
要解决此问题,您必须从给定的 postgis 安装创建一个符号链接到所需的 postgresql@V
This example for [email protected]
这个 [email protected] 的例子
ln -s /usr/local/share/postgresql/extension/postgis* /usr/local/Cellar/[email protected]/9.6.6/share/[email protected]/extension/
ln -s /usr/local/lib/postgresql/postgis-2.3.so /usr/local/Cellar/[email protected]/9.6.6/lib/postgis-2.3
ln -s /usr/local/lib/postgresql/rtpostgis-2.3.so /usr/local/Cellar/[email protected]/9.6.6/lib/
before running these commands, please check postgresql version and file path in your system
在运行这些命令之前,请检查系统中的 postgresql 版本和文件路径
Thanks this gistfor help.
感谢这个要点的帮助。
回答by Gwen Au
I had a similar problem with full details here. When the server is mentioned in your Postgres console, it means that you're referencing an older codebase. Stop that server and launch the correct server with the following commands.
我有一个类似的问题,这里有完整的细节。当您的 Postgres 控制台中提到服务器时,这意味着您正在引用较旧的代码库。停止该服务器并使用以下命令启动正确的服务器。
$ brew services list
That will give you a list of database servers that are running.
这将为您提供正在运行的数据库服务器列表。
$ brew services stop postgresql@<older-version>
$ brew services start postgresql