我需要为PostGIS
安装扩展名PostgreSQL
,以便可以使用地理数据库。
这是我所做的:
city
的数据库并已连接到数据库。postgis
的命令(根据我的shell历史记录...)
sudo apt install postgresql-10-postgis-2.4
sudo apt install postgresql-10-postgis-scripts
sudo apt install postgresql-10-pgrouting
sudo apt install postgis
然后我尝试在数据库city
中创建扩展名,但是出现以下错误:
postgres@yuqiong-G7-7588:~$ psql
psql (11.1 (Ubuntu 11.1-1.pgdg16.04+1), server 9.5.14)
Type "help" for help.
postgres=# \c city
psql (11.1 (Ubuntu 11.1-1.pgdg16.04+1), server 9.5.14)
You are now connected to database "city" as user "postgres".
city=# CREATE EXTENSION postgis;
ERROR: could not open extension control file "/usr/share/postgresql/9.5/extension/postgis.control": No such file or directory
结果,我怀疑postgis
扩展名未成功安装,因为在尝试检查其版本时也遇到此错误:
city=# select postgis_version();
ERROR: function postgis_version() does not exist
LINE 1: select postgis_version();
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
我想念什么?如果您能指出我的理解上的漏洞,那就太好了。谢谢!
答案 0 :(得分:3)
psql(11.1(Ubuntu 11.1-1.pgdg16.04 + 1),服务器9.5.14 )
您连接到错误的服务器,如果有多个不同的postgres服务器在运行,则可以尝试连接到另一个端口,例如5433或5434
看来您已安装了至少三个Postgresql版本:9.5.14、10。*和11.1,已为版本10安装了Postgis,这意味着您需要连接到Postgresql版本10服务器才能创建扩展名。
尝试运行:
psql -p 5433
看看是否连接到正确的postgresql服务器
然后,如果城市数据库不存在,则需要创建它,然后连接到该数据库。然后,您应该可以创建扩展名