从源代码安装 postgresql 后如何使用 pg_trgm
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14292800/
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
How to use pg_trgm after postgresql installation from source
提问by Daniel Vérité
After succesfully installing postgresql 9.2.2 from source (on OpenSUSE 11.4, which does not have this version in the repositories), I am trying to restore a database that makes use of the pg_trgm extension. This results in errors because pg_trgm is not found.
从源代码成功安装 postgresql 9.2.2 后(在 OpenSUSE 11.4 上,存储库中没有此版本),我尝试恢复使用 pg_trgm 扩展的数据库。这会导致错误,因为找不到 pg_trgm。
From this StackOverflow question: Similarity function in Postgres with pg_trgm, I gather that pg_trgm should be in /usr/share/postgresql//contrib, but there is no contrib folder anywhere in my /usr tree.
从这个 StackOverflow question: Similarity function in Postgres with pg_trgm 来看,我认为 pg_trgm 应该在 /usr/share/postgresql//contrib 中,但在我的 /usr 树中的任何地方都没有 contrib 文件夹。
Also, I cannot seem to find a clear explanation of how the postgres extension mechanism works, or how to manually install an extension.
此外,我似乎找不到关于 postgres 扩展机制如何工作或如何手动安装扩展的明确解释。
There is a contrib folder in the postgresql source tree, but I am not sure how to use this. Should I manually copy this somewhere to /usr tree? Can anyone point me to (or give) an explanation of how to install an extension like pg_trgm in postgresql?
postgresql 源代码树中有一个 contrib 文件夹,但我不确定如何使用它。我应该手动将它复制到 /usr 树吗?任何人都可以指出(或给出)有关如何在 postgresql 中安装 pg_trgm 之类的扩展的解释吗?
回答by Daniel Vérité
Assuming you have configured postgresql with ./configure
, it has used the default prefix /usr/local/pgsql
, so that everything gets installed below that directory.
假设您已使用 配置了 postgresql ./configure
,它使用了默认前缀/usr/local/pgsql
,以便所有内容都安装在该目录下。
The answer you link to relates to Debian, which uses a different layout that conforms to the Debian policy, but in your case /usr/share...
is irrelevant. Anyway it's not really necessary to know that in order to install stuff from contrib, since there is no need to copy anything manually.
您链接的答案与 Debian 相关,它使用符合 Debian 政策的不同布局,但与您的情况/usr/share...
无关。无论如何,为了从 contrib 安装东西并不是真的有必要知道,因为不需要手动复制任何东西。
To install the pg_trgm
extension from source, there are two steps:
要从pg_trgm
源代码安装扩展,有两个步骤:
1) build and install it from your postgresql source tree:
1) 从你的 postgresql 源代码树构建并安装它:
$ cd /path/to/src/postgresql-9.2.2/contrib/pg_trgm $ make $ sudo make install # or su -c 'make install' if you don't use sudo
2) activate it with psql
in your database:
2)psql
在您的数据库中激活它:
$ sudo -u postgres psql -d database -c "create extension pg_trgm;"
To have it activated by default on any database created in the future, apply this command to the template1
database.
要在以后创建的任何数据库上默认激活它,请将此命令应用于template1
数据库。
回答by Alex
I've use Postgresql in the Centos 7 and the package with the pg_trgm allowed to install:
我在 Centos 7 和允许安装 pg_trgm 的包中使用了 Postgresql:
$yum install postgresql-contrib
$yum 安装 postgresql-contrib