如何在 PostgreSQL 9.0 上安装 hstore 模块(MacPorts 安装)?
我通过 MacPorts 在我的笔记本电脑上安装了一个可爱的 PostgreSQL 9.0 服务器。我想启用 hstore 模块,但我找不到任何安装这些模块的说明可选模块(我也无法在 /opt/local/share/postgresql90/contrib/
中找到任何与 hstore 相关的代码)。
我已经在这里找到了一些与hstore相关的SQL ,但我不确定它来自哪里,或者它是否与 PostgreSQL 9.0 兼容。
那么,如何在安装了 MacPorts 的 Postgres 9.0 服务器上启用 hstore 模块?
I have a lovely PostgreSQL 9.0 server installed on my laptop via MacPorts. I would like to enable the hstore module, but I can't find any instructions for installing these optional modules (nor can I find any hstore-related code in /opt/local/share/postgresql90/contrib/
).
I have found some hstore-related SQL here, but I'm not sure where it comes from or if it's compatible w/ PostgreSQL 9.0.
So, how do I enable the hstore module on my MacPorts-installed Postgres 9.0 server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以告诉 MacPorts 构建 hstore。方法如下。
如果您已经安装了
postgresql
,则需要先将其卸载(这不会影响您的数据或用户),因为install
操作不会重新安装已经存在的安装端口。强制卸载 (-f
) 因为postgresql91-server
是依赖的并且会阻止卸载。编辑 Portfile 并将
hstore
添加到以set contribs
开头的行的列表中:(重新)显式从源安装 (
-s
)构建 hstore 扩展:然后为每个要使用它的数据库加载一次 hstore:
在 >= 9.1 中:
CREATE EXTENSION hstore;
在 9.0 中:
psql -U postgres -f /opt/local/share/postgresql90/contrib/hstore.sql
请注意,此过程适用于 postgresql92,只需将“92”替换为“91”即可。
You can tell MacPorts to build hstore. Here's how.
If you already have
postgresql
installed, you will need to uninstall it first (this won't touch your data or users) because theinstall
action will not re-install an already installed port. The uninstall is forced (-f
) becausepostgresql91-server
is dependent and will prevent uninstall.Edit the Portfile and add
hstore
to the list on the line which begins withset contribs
:(Re)install from source explicitly (
-s
) to build the hstore extension:Then load hstore, once for each of your databases in which you want to use it:
In >= 9.1:
CREATE EXTENSION hstore;
In 9.0:
psql -U postgres -f /opt/local/share/postgresql90/contrib/hstore.sql
Note this process works for postgresql92 by just substituting "92" for "91".
看来 PostgreSQL 9.1 的端口现在包含 hstore,但仍然需要启用。正常安装并启动数据库。
编辑:在另一台计算机上安装效果不佳。 hstore 没有随底座一起安装(我可能已经尝试其他解决方案使其可用)。因此,请在上面的加载命令之前执行此操作:
要启用 hstore 扩展,请在将使用 hstore 的数据库中使用新的“创建扩展”SQL 命令。如果将其安装到 template1 数据库中,则之后创建的所有数据库都将具有 hstore 扩展名。
如果您只需要特定数据库中的扩展:
It seems that the port for PostgreSQL 9.1 now includes hstore, but it still needs to be enabled. Install and start the database normally.
EDIT: Installing in another computer didn't work as well. The hstore was not installed with the base (I may have made it available trying other solutions). So do this BEFORE the load command above:
To enable the hstore extension, use the new "create extension" SQL command in the database(s) you will use hstore. If you install it into the template1 database, all databases created afterwards will have the hstore extension.
If you only need the extension in a particular database:
我不能说适用于 MacOS(或任何 MacPorts),但在 Windows 上,share/contrib 中有一个文件“hstore.sql”,它引用了一个库“hstore.dll”,它是常规发行版的一部分。
这包含在 EnterpriseDB 的一键安装程序中。我假设 MacOS 的一键安装程序也包含该模块:
http:// /www.enterprisedb.com/products-services-training/pgdownload#osx
I can't say for MacOS (or whatever MacPorts is), but on Windows there is a file "hstore.sql" in share/contrib and it references a library "hstore.dll" which is part of the regular distribution.
This was included in the one click installer from EnterpriseDB. I would assume that the one click installer for MacOS includes that module as well:
http://www.enterprisedb.com/products-services-training/pgdownload#osx
Joey Adam 的解决方案是正确的,但与 postgres 9.1 有点过时:
我做了与他的帖子不同的以下操作:
Joey Adam's solution is correct, but has become slightly dated with postgres 9.1:
I did the following differently from his post: