postgresql Postgis 安装

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8459361/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-20 23:27:47  来源:igfitidea点击:

Postgis install

postgresqlpostgis

提问by Orn Kristjansson

I have Postgres version 8.4.8

我有 Postgres 8.4.8 版

select version();
PostgreSQL 8.4.8 on i686-pc-linux-gnu, compiled by GCC gcc-4.4.real (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5, 32-bit

Installed Postgis via the synaptic package manager, (postgis and postgresql-8.4-postgis) everything seemed to go fine. Then when I try to verify the Postgis version, things are not fine. Both of these give the same error.

通过突触包管理器安装 Postgis,(postgis 和 postgresql-8.4-postgis)一切似乎都很顺利。然后当我尝试验证 Postgis 版本时,事情并不好。这两个都给出了相同的错误。

SELECT PostGIS_version();
SELECT PostGIS_full_version();

ERROR:  function postgis_full_version() does not exist
LINE 1: SELECT PostGIS_full_version();
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

The package manager claims Postgis is installed. How can I verify that the install worked or didn't work ?

包管理器声称已安装 Postgis。如何验证安装是否有效?

回答by Erwin Brandstetter

PostGIS needs to be installed per database. Existing databases are not altered automatically. Run the install script as follows.

每个数据库都需要安装 PostGIS 。现有数据库不会自动更改。运行安装脚本如下。

In PostgreSQL 8.4 you may also need to create the language plpgsql. For 9.0+ it is the default procedural language and installed automatically. In your database:

在 PostgreSQL 8.4 中,您可能还需要创建语言 plpgsql。对于 9.0+,它是默认程序语言并自动安装。在您的数据库中:

createlang plpgsql yourdatabase

Can't do harm. If plpgsql is already installed it will just yield an error telling you so. Go to the install dir. In Debian Squeeze the contrib packages lie here (may be different in Ubuntu). In a shell:

不能造成伤害。如果 plpgsql 已经安装,它只会产生一个错误告诉你。转到安装目录。在 Debian Squeeze 中,contrib 软件包位于此处(在 Ubuntu 中可能不同)。在外壳中:

cd /usr/share/postgresql/8.4/contrib/postgis-1.5

Then execute (as postgres user or you have to provide username / pw):

然后执行(以 postgres 用户身份或您必须提供用户名/密码):

psql -d yourdatabase -f postgis.sql
psql -d yourdatabase -f spatial_ref_sys.sql

You may also want to install the comments to your shiny new functions (optional). In Debian Squeeze the install file lies in the /contrib main directory:

您可能还想将注释安装到您闪亮的新功能中(可选)。在 Debian Squeeze 中,安装文件位于 /contrib 主目录中:

cd /usr/share/postgresql/8.4/contrib
psql -d yourdatabase -f postgis_comments.sql

If you want PostGIS to be installed with everynew database in the cluster by default, install it to your template1database also. Read more about that in the manual.

如果您希望 PostGIS默认与集群中的每个新数据库一起安装,请将其template1也安装到您的数据库中。在手册中阅读更多相关信息

Sources for PostGIS installation (on Ubuntu):

PostGIS 安装的来源(在 Ubuntu 上):

http://postgis.net/docs/manual-2.1/postgis_installation.html
http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/

http://postgis.net/docs/manual-2.1/postgis_installation.html
http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/

PostgreSQL 9.1+

PostgreSQL 9.1+

With PostgreSQL 9.1 or newer you can use the more convenient CREATE EXTENSION:

使用 PostgreSQL 9.1 或更高版本,您可以使用更方便的CREATE EXTENSION

CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;

Your distribution is probably shipping the extension ready for installation. If not, consider the chapter "Building PostGIS Extensions and Deploying them"in the PostGIS manual.

您的发行版可能正在运送准备安装的扩展。如果没有,请考虑PostGIS 手册中的“构建 PostGIS 扩展并部署它们”一章。