Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Has been installed postgis but can not create extention: ERROR: could not open extension control file ~/postgis.control": No such file or directory

I'm using ubuntu 18.0.4 and I have a postgresql database. Obviously I have installed postgresql. I also have been installed postgis:

sudo apt install postgis postgresql-11-postgis-2.5

by using this command:

dpkg -l | grep postgresq

it returns:

ii  pgdg-keyring                          2018.2                                          
all          keyring for apt.postgresql.org
ii  postgresql                            12+210.pgdg18.04+1                              
all          object-relational SQL database (supported version)
ii  postgresql-11                         11.6-1.pgdg18.04+1                              
amd64        object-relational SQL database, version 11 server
ii  postgresql-11-postgis-2.5             2.5.3+dfsg-2.pgdg18.04+1                        
amd64        Geographic objects support for PostgreSQL 11
ii  postgresql-11-postgis-2.5-scripts     2.5.3+dfsg-2.pgdg18.04+1                        
all          Geographic objects support for PostgreSQL 11 -- SQL scripts
ii  postgresql-12                         12.1-1.pgdg18.04+1                              
amd64        object-relational SQL database, version 12 server
ii  postgresql-client-11                  11.6-1.pgdg18.04+1                              
amd64        front-end programs for PostgreSQL 11
ii  postgresql-client-12                  12.1-1.pgdg18.04+1                              
amd64        front-end programs for PostgreSQL 12
ii  postgresql-client-common              210.pgdg18.04+1                                 
all          manager for multiple PostgreSQL client versions
ii  postgresql-common                     210.pgdg18.04+1                                 
all          PostgreSQL database-cluster manager
ii  postgresql-contrib                    12+210.pgdg18.04+1                              
all          additional facilities for PostgreSQL (supported version

and by using this command:

dpkg -l | grep postgis

it returns:

ii  postgis                               3.0.0+dfsg-2~exp1.pgdg18.04+1                   
amd64        Geographic objects support for PostgreSQL
ii  postgresql-11-postgis-2.5             2.5.3+dfsg-2.pgdg18.04+1                        
amd64        Geographic objects support for PostgreSQL 11
ii  postgresql-11-postgis-2.5-scripts     2.5.3+dfsg-2.pgdg18.04+1                        
all          Geographic objects support for PostgreSQL 11 -- SQL scripts

but when I try to create the extension:

CREATE EXTENSION postgis;

it raises this error:

ERROR: could not open extension control file >"/usr/share/postgresql/12/extension/postgis.control": No such file or directory

why I can't create this extension while I have installed every thing?

like image 742
MHB Avatar asked Dec 03 '19 08:12

MHB


1 Answers

You installed PostGIS for your PostgreSQL v11 installation, but when you are trying to create the extension, you are connected to a v12 database.

You have to either connect to the v11 database or install PostGIS for your v12 installation.

like image 144
Laurenz Albe Avatar answered Sep 20 '22 02:09

Laurenz Albe