【问题标题】:Postgis install [closed]Postgis安装[关闭]
【发布时间】:2012-01-17 13:32:29
【问题描述】:

我有 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

通过突触包管理器(postgis 和 postgresql-8.4-postgis)安装了 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.

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

【问题讨论】:

  • “如果您的问题通常涵盖software tools commonly used by programmers,那么您来对地方了”?
  • @BradKoch 这听起来更像是数据库管理,而不是程序员常用的工具。
  • 从经验上讲,这绝对是在开发中使用PostGIS时比较常见的一个常见问题。它可以合理地成为至少 3 个不同 SE 网站的主题。

标签: postgresql postgis


【解决方案1】:

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

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

createlang plpgsql yourdatabase

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

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

然后执行(作为 postgres 用户或者你必须提供用户名/密码):

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

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

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

如果您希望 PostGIS 默认与集群中的每个新数据库一起安装,请将其也安装到您的 template1 数据库中。阅读more about that in the manual

PostGIS 安装源(在 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 或更高版本,您可以使用更方便的CREATE EXTENSION

CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;

您的发行版可能正在运送准备安装的扩展。如果没有,请考虑 PostGIS 手册中的 "Building PostGIS Extensions and Deploying them" 章节。

【讨论】:

  • 我什至没有想到它是每个数据库,这是有道理的,thnx
  • 我也无法让 PostGIS_full_version(); 方法工作,但到目前为止 postgis 正在工作。我知道那里有一些教程说这种方法可以确认它,但是尝试创建一些 postgis 允许的特殊列,例如 geometry 列或其他东西,这应该可以作为测试。
  • 从 shell 运行“createlang plpgsql yourdatabase”,而不是 sql。
猜你喜欢
  • 1970-01-01
  • 2011-06-05
  • 2014-05-08
  • 1970-01-01
  • 1970-01-01
  • 2023-03-18
  • 2023-03-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多