How to install Postgresql and Postgis in Windows 10 with WSL and Debian - Tutorial

howToInstallPostgresqlandPostgisinWindows10.PNG

The normal method to install Postgresql and Postgis requires the set up of several binaries and the workflow is usually on graphical user interfaces (GUI). We wanted to come with a way to install Postgresql and Postgis in Windows 10 while keeping the shell experience from Linux. This tutorial shows the procedure to install the database inside a Debian application (it could be Ubuntu as well) in Windows 10 that can actually be accessible from QGIS.


Instructions

Enable Windows Subsystem for Linux (WSL) following the Manual Installation Steps from this link:

https://docs.microsoft.com/en-us/windows/wsl/install-win10

Install Debian or Ubuntu from the Windows Store

Insert username: “hatari” and password: “labs”

Update the Debian repositories:

sudo apt update

Install postgis that actually install postgresql 11:

sudo apt install postgis

Check status of postgresql:

sudo service postgresql status

Start postgresql engine:

sudo service postgresql start

Check postgresql version:

psql --version

Enter psql as user postgres

sudo -u postgres psql

Create user:

CREATE USER gis WITH PASSWORD 'gis';

Create database:

CREATE DATABASE geodatabase OWNER gis;

Change to the geodatabase:

\c geodatabase;

Enable postgis on database:

CREATE EXTENSION postgis;

Check the created files:

\dt

On CMD check that the port 5432 is working running as Administrator:

netstat -ab

Open QGIS and connect to Postgres as:

imagen_2021-06-02_094956.png

Tutorial

 
Comment

Saul Montoya

Saul Montoya es Ingeniero Civil graduado de la Pontificia Universidad Católica del Perú en Lima con estudios de postgrado en Manejo e Ingeniería de Recursos Hídricos (Programa WAREM) de la Universidad de Stuttgart con mención en Ingeniería de Aguas Subterráneas y Hidroinformática.

 

Suscribe to our online newsletter

Subscribe for free newsletter, receive news, interesting facts and dates of our courses in water resources.