How to Install PostgreSQL on Windows

Perform the following steps to install the PostgreSQL database server on Windows 10/Server.

Open a web browser and point it to www.enterprisedb.com/downloads/postgres-postgresql-downloads and download the PostgreSQL version you want to install.

download postgres for windows

After downloading PostgreSQL, double-click and run the installer, and it will guide you through the installation process.

Accept the default installation directory and click Next (The Postgres installation directory is where all the executable and configuration files are stored in Windows).

Accept the default installation directory

Select the Components you want to install (PostgreSQL Server, pgAdmin 4, Stack Builder, and Command Line Tools).

Select the Components you want to install

Click Next and proceed with the default Data Directory. This is the location where PostgreSQL stores your data (databases).

PostgreSQL Data Directory

Configure a password for the user postgres. As a database administrator, you will use this user account to administrate the Postgres server on Windows.

Configure a password for the user postgres

The Postgres port number should be 5432 (do not change the default port unless you have a good reason).

Windows PostgreSQL port

In the following window, select the Locale (Language) to be used by PostgreSQL Server.

PostgreSQL Language

After the Postgres installation has concluded, click the finish button to exit the setup (Deselect the Stack Builder, no deed to run it).

Server Configurations

PostgreSQL on Windows is installed as a service. To access Postgres service, go to Start | Windows Administrative Tools | Services.

Postgres service windows

You can use service windows to start, stop and restart PostgreSQL Server.

The postgresql.conf is the main configuration file of the database cluster. It is located in the data directory. For example, if you installed PostgreSQL 13, the full path will be C:\Program Files\PostgreSQL\13\data\postgresql.conf.

Inside the data directory, the base subdirectory contains all databases and tables.

Connecting to the PostgreSQL Server

PostgreSQL ships with psql, a command-line client that we use to connect and administer databases and the cluster itself.

You will find a shortcut to open psql (SQL Shell) under the start menu, as shown in the previous screenshot.

psql windows

The default username is postgres, the password is the password you created during the installation.

How to Install PostgreSQL on Windows