Postgres and PostGis , can not create extension - postgresql

I have installed postgresql 9.4 and postgis 2.1.5, and also dependecies.
But when I fire in my terminal:
sudo -u postgres psql -c "CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology;" test_base
I get:
ERROR: could not load library "/usr/lib/postgresql/9.4/lib/postgis-2.1.so": liblwgeom-2.1.5.so: cannot open shared object file: No such file or directory
which tells me that I'm missing something, after some googling around I have not found any solution :(
Is someone have experience with this?

I had the same problem on my Ubuntu 14.04 with postgresql 9.4
I reinstalled postgis and this solved the problem:
apt-get install postgis

Related

How do i install postgis on ubuntu server?

My pc showing i have two versions of Postgres installed.
postgres=# \c viserver
psql (12.2 (Ubuntu 12.2-4), server 11.7 (Ubuntu 11.7-0ubuntu0.19.10.1))
I installed PostGIS using sudo apt-get install postgis but it installed PostGIS in Postgres 12.
But I want to install it in Postgres 11. cause my server version using postgres 11.
because CREATE EXTENSION postgis; on a database giving error
ERROR: could not open extension control file "/usr/share/postgresql/11/extension/postgis.control": No such file or directory
the error you see means that some packages are not installed.
To have postgis.control please check and install
postgresql-11-postgis-X.Y (e.g. X.Y = 2.5)
and
postgresql-11-postgis-X.Y-scripts
Regards,
Mohamad
It helped what S. Mohamad explained. But I want to share the exact answer.
Steps to resolve the error:
Try to run sudo apt install postgresql-11-postgis. This will install but provide suggestion what to install like below.
You can see the 2 versions of postgis I installed the latest version by sudo apt install postgresql-11-postgis-3
After installing required package you can run CREATE EXTENSION postgis; in postgres and it will show you following:
Yay!! No errors.

CREATE EXTENSION postgis fails,

I am on Ubuntu 18.04 with the psql (PostgreSQL) 12.2 (Ubuntu 12.2-2.pgdg18.04+1)
Running temba=# create extension postgis; fails with the following error
ERROR: could not open extension control file "/usr/share/postgresql/10/extension/postgis.control": No such file or directory
I ran find /usr -name postgis.control only to find out postgis.control is inside a folder named 12 instead of 10
laptop#xyz-x:~$ find /usr -name postgis.control
/usr/share/postgresql/12/extension/postgis.control
Edit 1
I have already ran sudo apt-get install postgis
Reading package lists... Done
Building dependency tree
Reading state information... Done
postgis is already the newest version (3.0.1+dfsg-2.pgdg18.04+1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
I ran this sudo apt install postgis postgresql-10-postgis-2.5 and it worked
I was not sure what version of postgres or postgis I needed, so I found sudo apt install postgis postgresql-postgis worked.
It either gave me the latest, or matched my installed postgres version.
I use Linux Mint and had this problem for postgres10, and also: could not access file "$libdir/postgis-2.4": No such file or directory following that. Installation of specific extension and scripts package cures it for me:
sudo apt install postgresql-10-postgis-2.4 postgresql-10-postgis-2.4-scripts Reading package lists... Done Building dependency tree Reading state information... Done postgresql-10-postgis-2.4-scripts is already the newest version (2.4.3+dfsg-4). postgresql-10-postgis-2.4-scripts set to manually installed. The following NEW packages will be installed libprotobuf-c1 postgresql-10-postgis-2.4
Then go, in my case to pgAdmin and CREATE EXTENSION postgis; returns successfully.
sudo apt install postgis postgresql-13-postgis-3 for postgres 13.1 and next CREATE EXTENSION postgis; (postgres command)
Alternatively, and easier, run sudo apt install postgis postgresql-12-postgis-2.5 for postgres12
Go to the file location where postgis is installed;
C:\Program Files\PostgreSQL\12\bin
Run stackbuilder.exe;
Select connected your database;
Select "Spatial Extensions" and install
If CREATE EXTENSION postgis is not working and giving you the error no such file or directory.then do follow the following steps:
Go to the file location where postgis is installed;
1.C:\Program Files\PostgreSQL\12\bin
2.Run stackbuilder.exe;
3.Select connected your database;
4.Select "Spatial Extensions" and install
and if you are stackbuilder is not responding wait for some time try with fast internet connection.
For PostgreSQL 14: sudo apt install postgis postgresql-14-postgis-3
Tested on Ubuntu 20.04

Install Postgis in Ubuntu 16.04 in with already postgresql 9.3 installed

In ubuntu 16.04 when I tried to install postgis with using apt-get install postgis postgresql-9.3-postgis-2.1 this command, it installed postgresql 9.6 and postgis-9.6 version. And when tried to create extension it gives error ERROR: could not open extension control file "/usr/share/postgresql/9.3/extension/postgis.control": No such file or directory.
postgres#db:~$ psql
psql (9.6.3, server 9.3.17)
Type "help" for help.
It seems that you didn't use sudo before apt-get which is causing issue with write permissions of your directory.
To prevent this error remove the installed version and reinstall it with sudo like,
sudo apt-get install postgis postgresql-9.3-postgis-2.1
Read more related with your issue and follow the steps to install specific version.

Can't use uuid and create an extension to use it

I want to use uuid in Postgresql 9.2 on Ubuntu 13. So when I tried to check whether is available or not, I did:
select uuid_generate_v4() as one;
And it gave me ERROR: function uuid_generate_v4() does not exist
Then I did CREATE EXTENSION "uuid-ossp";
ERROR: could not open extension control file "/usr/share/postgresql/9.2/extension/uuid-ossp.control": No such file or directory
Well, what do I do next?
By the way, SELECT * FROM pg_available_extensions; returns plpsql (1.0) only.
The operating system package that contains the extension is not installed. To install it:
apt-get install postgresql-contrib-9.2
For anyone using the asdf version manager with the asdf-postgres plugin, installing postgres versions as follows fixes this issue:
POSTGRES_EXTRA_CONFIGURE_OPTIONS=--with-uuid=e2fs asdf install postgres <VERSION>
For you guys, who installed postgres using postgres rpm repo on Fedora or similar distro:
sudo dnf install postgresql-contrib
installs a package from default fedora repo, which conflicts with postgres, like:
/usr/pgsql-12/lib/libpq.so.5: no version information available (required by psql)
Right way is
sudo dnf install postgresql12-contrib
You can double check it during install, it has to be from pgdg12, same as postgresql-server
(you have insert your postgres version instead of '12')
If you still get the error, try to run manually the two SQL files inside /usr/share/postgresql/9.X/extension/uuid-ossp*.sql into your database

Postgres create POSTGIS extension error with CentOS 6

I am running PostgreSQL 9.3 with Postgis 2.0 on CentOS 6.3.
I installed PostgreSQL and PostGIS according to this instructions:
http://trac.osgeo.org/postgis/wiki/UsersWikiPostGIS21CentOS6pgdg
When trying to create Postgis extension
Create Extension Postgis;
I get the following error,
ERROR: could not load library "/usr/pgsql-9.3/lib/rtpostgis-2.1.so": libhdf5.so.6: cannot open shared object file: No such file or directory
May I know how to install the POSTGIS extension successfully?
I have CentOs 6.5 and did this:
1) Install following packages
hdf5-1.8.11-42.1.x86_64.rpm
json-c-0.10-2.1.x86_64.rpm
libhdf5-8-1.8.11-42.1.x86_64.rpm
libhdf5_hl8-1.8.11-42.1.x86_64.rpm
I don't know if I can link files directly here, so look for those files at rpm.pbone.net, download CentOS 6 version.
2) As Postgis requires version hdf5 version 6, you have to execute this commands as root (# is prompt)
# cd /usr/lib64
# ln -s libhdf5_hl.so.8 libhdf5_hl.so.6
# ln -s libhdf5.so.8 libhdf5.so.6
PS Don't forget to install postgresql contrib package, as Postgis requires fuzzystrmatch extension for some modules.
Have you tried installing the package that contains libhdf5 and then tried running again the create extension command? Apparently postgis is linked to that package which is not present on your system.