Postgresql:无法访问文件?$libdir/postgis-2.1 ?无此文件或目录

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

Postgresql: Can't access to file ? $libdir/postgis-2.1 ? no such file or directory

postgresqlmigrationpostgis

提问by AnomalySmith

I guess this is a known issue but since I have used a script that removed my postgresql-9.4-postgis-2.1, I'm now unable to get rid of this SQL error under Debian.

我想这是一个已知问题,但由于我使用了一个脚本来删除我的 postgresql-9.4-postgis-2.1,我现在无法在 Debian 下摆脱这个 SQL 错误。

Can't access to file ? $libdir/postgis-2.1 ? no such file or directory

无法访问文件?$libdir/postgis-2.1 ?无此文件或目录

I've done the following:

我做了以下工作:

- Remove new unwanted postgresql-9.5-postgis-2.2 package installed
- Reinstalling postgresql-9.4-postgis-2.1, postgresql-9.4-postgis-scripts and postgis
- Using SQL: ALTER EXTENSION postgis UPDATE TO '2.1.4' --under postgres user
- Using SQL: ALTER EXTENSION postgis_topology UPDATE TO '2.1.4' --under postgres user

And SELECT * FROM pg_available_extensions;returns

SELECT * FROM pg_available_extensions;返回

[...]
postgis 2.1.4   2.1.4   PostGIS geometry, geography, and raster spatial types and functions.

But still this message when accessing object like tables that uses geometry type.

但是在访问使用几何类型的表之类的对象时仍然会出现此消息。

Any idea?

任何的想法?

采纳答案by AnomalySmith

Finally "solve" the issue compiling from sourcepostgis 2.2.2 (that also requires gdal, proj4 and geos) and then issuing

最后“解决”从源postgis 2.2.2(也需要 gdal、proj4 和 geos)编译的问题,然后发出

CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;

since DROP EXTENSION postgis;tells me postgis wasn't present anymore.

因为DROP EXTENSION postgis;告诉我 postgis 不再存在。

And finally:

最后:

ALTER EXTENSION postgis UPDATE TO '2.2.2';
ALTER EXTENSION postgis_topology UPDATE TO '2.2.2';

Got access again to my geom data and functions from PostgreSQL 9.4. It seems that compiling from source updated correctly the variable path for postgresql and installed /usr/lib/postgresql/9.4/lib/postgis-2.2.so that wasn't present anymore (for postgis-2.1.so as well), even with (re)installing from apt-get.

从 PostgreSQL 9.4 再次访问我的 geom 数据和函数。似乎从源代码编译正确更新了 postgresql 的变量路径并安装了 /usr/lib/postgresql/9.4/lib/postgis-2.2.so 不再存在(对于 postgis-2.1.so 也是如此),即使使用(重新)从 apt-get 安装。

Hope this will help.

希望这会有所帮助。

回答by David Hine

First run (as postgres administrator)

首次运行(作为 postgres 管理员)

ALTER EXTENSION postgis UPDATE;

If this returns successfully, then check what version you have

如果成功返回,请检查您的版本

SELECT PostGIS_Full_Version();

If however, the server returns that it cannot find the extension postgis, then run

但是,如果服务器返回找不到扩展名 postgis,则运行

CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;
ALTER EXTENSION postgis UPDATE;

and again check by running

并通过运行再次检查

SELECT PostGIS_Full_Version();

回答by lakshmi narayana

If you are using ubuntu

如果您使用的是 ubuntu

Enter in postgres interactive shell by using below command

使用以下命令进入 postgres 交互式 shell

  • sudo -u postgres psql

  • \c database_name;

  • ALTER EXTENSION postgis UPDATE TO "2.4.4";

  • SELECT PostGIS_Full_Version();

  • 须藤 -u postgres psql

  • \c 数据库名称;

  • 更改扩展 postgis 更新到“2.4.4”;

  • 选择 PostGIS_Full_Version();