How to install pgAdmin 4 in Ubuntu for PostGIS
Learn how to install and configure pgAdmin 4 in Ubuntu for PostGIS with this step-by-step guide. Get started on managing your PostgreSQL databases and spatial data today.
Contents
How to install pgAdmin 4 in Ubuntu for PostGIS
This short article shows the process to be able install pgAdmin4 in Ubuntu, as well as its validation and configuration for its implementation to work with Space Databases based on PostgreSQL and PostGIS.
What is pgAdmin?
Basically, pgAdmin is a graphical interface to work with the database PostgreSQL. It is an essential management tool to work with open source databases.
PgAdmin version 4 (pgAdmin4) is the most recent and, unlike its predecessors, written in C + +, it is written in Python.
The application allows us to carry out all kinds of tasks of management, consultation and analysis of information stored in databases, also with geographic information.
Within the sector GIS open source, it is very common to use pgAdmin as a Database Management System ( RDBMS ).
In fact, it is specifically intended for combination with PostgreSQL, on which to implement PostGIS.
It has a clean, friendly design and is easy to configure. In addition, it includes support for visualize GIS cartographic layers vector type, which is a great point in their favor for GIS professionals.
Once PostgreSQL and PostGIS are installed on our machine Ubuntu, we can move on to install pgAdmin4. Let’s see how to perform its installation.
If you still don’t have PostgreSQL and PostGIS, we recommend that you review our article on the installation process of PostGIS in Linux to start working with spatial databases.
How to install pgAdmin4 in Ubuntu
For install pgAdmin4 in Ubuntu, we must first copy the certificates and password with the following command:
1 2 | sudo apt install curl ca-certificates gnupg curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - |
Subsequently, we will enter the following command, replacing « bionic » with the Ubuntu version that we have installed.
1 | deb http://apt.postgresql.org/pub/repos/apt/ bionic -pgdg main |
To know for sure the name of the Ubuntu version if we do not know it, we must enter the command:
1 | lsb_release -c |
In our case, this is version 18.04 Bionic. Thus, we will specify the name of the version in the command as follows:
1 | deb http://apt.postgresql.org/pub/repos/apt/ bionic -pgdg main |
If your version is different, you should replace “ bionic ” with the name that the previous command returned. The same with the following command:
1 | sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main" > /etc/apt/sources.list.d/pgdg.list' |
Below we will update the packages and install pgadmin4:
1 2 | sudo apt-get update sudo apt-get install postgresql-11 pgadmin4 |
The download and installation of pgAdmin4 packages. The process may take a few minutes.
Check installation and configure pgAdmin4
We will try to start pgAdmin4 from the browser, in our case installed on localhost and port 4326 by default.
We can do it manually by launching the program or from the console by entering the command:
1 | pgadmin4 |
In case it does not allow opening with your default browser, you can change the order from Configuration > Runtime > Browser Command and insert:
1 | /usr/bin/firefox %URL% |
or, depending on the browser you want to use:
1 | /usr/bin/chromium-browser/ %URL% |
With this you should be able to access the pgAdmin4 web interface with your browser.
Create the PostGIS extension in a database
Once opened pgAdmin4 access the server you have available and / or create / connect to a database from the side tree menu.
Having selected the database, check that it allows establishing the PostGIS integration, generating a new one SQL query:
1 | CREATE EXTENSION postgis; |
If it doesn’t return any errors and pgAdmin4 validates the query, everything should be correct. You can make sure by going to the selected database > Extensions > postgis.
At this time the database is ready to admit and work with spatial data for storage, analysis and transformation from pgAdmin4.
There should be the created extension, enabling all the functions that PostGIS provides to PostgreSQL.
If you want know more about PostGIS, you can review our article that includes the 25 main functions for spatial analysis that incorporates the PostGIS extension.
Also, once the installation and configuration of PostGIS and pgAdmin4 has been carried out, we can connect this graphic tool to manage databases with QGIS, the most popular OpenSource desktop GIS.
Connect both components for geoinformation work using Geographic Information Systems and spatial databases is a great advantage for most GIS projects.
Read More