Skip to content
Runbook

Install PostgreSQL on Windows

Open source SQL relational database, robust and standards-compliant.

Databasesqlrdbmsrelationalaciddatabase

Installation

Installer (winget) · winget
winget install -e --id PostgreSQL.PostgreSQL.17

Installs the server, pgAdmin and the command-line tools, and registers a Windows service.

Verify the installation

Verify
psql --version

Service

Start
net start postgresql-x64-17
Stop
net stop postgresql-x64-17
Status
sc query postgresql-x64-17
Restart
net stop postgresql-x64-17 && net start postgresql-x64-17

Important files

TypePathDescription
dataC:\Program Files\PostgreSQL\17\dataCluster data directory.
configC:\Program Files\PostgreSQL\17\data\postgresql.confServer configuration, located in the data directory.
configC:\Program Files\PostgreSQL\17\data\pg_hba.confClient authentication rules.
binaryC:\Program Files\PostgreSQL\17\binExecutables (psql, pg_dump, pg_ctl...) to add to the PATH.

Default ports

5432

Command-line tools

  • psqlInteractive SQL client.
  • pg_dumpLogical backup of a database.
  • pg_restoreRestore from a custom-format backup.
  • createdbQuick creation of a database.
  • pg_ctlLow-level server control.

Uninstall

Uninstall
winget uninstall -e --id PostgreSQL.PostgreSQL.17

The data directory may remain; delete it manually to erase everything.

Good to know

  • The exact name of the Windows service depends on the major version (postgresql-x64-17 for 17) — verify depending on the installed version.
  • The EnterpriseDB installer sets a password for the postgres superuser during installation; keep it safe.

Installation on Windows

winget install -e --id PostgreSQL.PostgreSQL.17 downloads and runs the EnterpriseDB installer. The bare PostgreSQL.PostgreSQL package is stuck on version 14 in the winget-pkgs repository, so we explicitly target PostgreSQL.PostgreSQL.17 to get version 17. It installs the server, the pgAdmin graphical interface, the command-line utilities, creates the data cluster and registers a Windows service that starts automatically.

The interactive installation asks for a password for the postgres superuser: write it down, it is required for any later connection.

Windows service and service name

PostgreSQL runs as a Windows service named according to the major version, for example postgresql-x64-17. The net start / net stop and sc query commands above use this name: adjust it if you install another version — verify depending on the version.

Adding psql to the PATH

The executables reside in C:\Program Files\PostgreSQL\17\bin. If psql is not recognized in the terminal, add this folder to the Path environment variable, or launch "SQL Shell (psql)" from the Start menu.

First connection

Connect to the server as the postgres superuser. The easiest way is to launch "SQL Shell (psql)" from the Start menu and accept the defaults (server localhost, port 5432, database postgres, user postgres), then enter the password set during installation. From a terminal where psql is on the Path, the equivalent command is:

psql -U postgres