For Windows installations, PostgreSQL 17.4 is installed using a PowerShell script that automates the installation process.
Right-click on PowerShell and select "Run as Administrator"
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Execute the pre-written PostgreSQL installation script (install-postgresql.ps1):
Basic usage with default parameters:
.\install-postgresql.ps1
Custom installation with parameters:
.\install-postgresql.ps1 -BaseDir "C:\PostgreSQL" -ServerPort 5433 -DataDir "C:\PostgreSQL\pgdata"
| Parameter | Description | Default Value |
|---|---|---|
| BaseDir | Installation directory for PostgreSQL | the script directory |
| ServerPort | Port number for PostgreSQL server | 5432 |
| DataDir | Data directory for PostgreSQL database cluster | data (inside installation directory) |
Example 1: Install with all default settings
.\install-postgresql.ps1
Example 2: Custom installation directory
.\install-postgresql.ps1 -BaseDir "C:\Program Files\PostgreSQL"
Example 3: Custom port
.\install-postgresql.ps1 -ServerPort 5433
Example 4: Full custom configuration
.\install-postgresql.ps1 -BaseDir "E:\Database\PostgreSQL" -ServerPort 5433 -DataDir "E:\Database\PostgreSQL\pgdata"
After the script completes, verify the installation by opening Command Prompt or PowerShell and running:
psql --version
Expected output: psql (PostgreSQL) 17.4
The PostgreSQL service should start automatically after installation.
PostgreSQL provides an official Windows installer available at the PostgreSQL Windows Downloads page. The installer offers both graphical and silent installation modes.