Installing PostgreSQL on Windows
Introduction
On Windows unlike many distributions, Linux PostgreSQL is not installed by default
Downloading
At the time of writing, the versions for
Windows
are provided through the company
EDB
Download link
This article uses version 12.14.1
Installation
Run the installer file postgresql-12.14-1-windows-x64.exe with administrator privileges
Installing PostgreSQL
Installing PostgreSQL
Installing PostgreSQL
Installing PostgreSQL
Installing Postgres 12 on Windows, image from www.eth1.ru Installing PostgreSQL If you expect a lot of data, it is better to allocate a separate disk for it.
Installing Postgres 12 on Windows, image from www.eth1.ru
Installing Postgres 12 on Windows, image from www.eth1.ru
Installing Postgres 12 on Windows, image from www.eth1.ru
Installing Postgres 12 on Windows, image from www.eth1.ru
Installing Postgres 12 on Windows, image from www.eth1.ru
Installing Postgres 12 on Windows, image from www.eth1.ru
Installing Postgres 12 on Windows, image from www.eth1.ru
Installing Postgres 12 on Windows, image from www.eth1.ru
Check the version
To check the version of the installed PostgreSQL, go to
C:\Program Files\PostgreSQL\12\bin
And run
.\psql -V
psql (PostgreSQL) 12.8
Configuration after installation
Go to the directory that you specified as the Data Directory and edit the files there pg_hba.conf
host all all 0.0.0.0/0 md5 host all all ::0/0 md5
And postgresql.conf
listen_addresses = '*'
Restart Postgres as follows:
Open
Control Panel → Administrative tools → Services
Find there postgresql-x64-12 right-click it and choose Restart
Restarting PostgreSQL
Add Postgres to PATH
Several examples of adding
the path to psql to PATH.
In my case
psql.exe
is in the folder C:\Program Files\PostgreSQL\12\bin
In
WSL
PATH=$PATH:/mnt/c/Program\ Files/PostgreSQL/12/bin
In Git Bash
PATH=$PATH:/c/Program\ Files/PostgreSQL/12/bin
In PowerShell you can check whether the path to Postgres is present using Select-String
echo $Env:Path | Select-String Postgres
You can add the path to Postgres to the end of Path as follows
$Env:Path += ';C:/Program Files/PostgreSQL/12/bin'
Add to the beginning of Path
$Env:Path = ';C:/Program Files/PostgreSQL/12/bin' + $Env:Path
Article author: Andrei Olegovich