π Installing PostgreSQL on Windows
PostgreSQL is one of the most powerful open-source relational databases used in production systems. It is widely used with frameworks like Django, FastAPI, Node.js, and Spring Boot.
This guide explains how to install PostgreSQL on Windows step-by-step.
π₯ Step 1: Download PostgreSQL
Open the official PostgreSQL website:
Click Download the Installer
You will be redirected to EnterpriseDB website
Download the latest PostgreSQL version for Windows
Example file name:
postgresql-16.x-windows-x64.exeβοΈ Step 2: Run the Installer
Double-click the downloaded .exe file
The Setup Wizard will open
Click Next
π Step 3: Choose Installation Directory
Default path usually:
C:\\Program Files\\PostgreSQL\\16You can keep the default.
Click Next
π§© Step 4: Select Components
Choose the components to install.
Typical components include:
Component | Description |
|---|---|
PostgreSQL Server | Main database server |
pgAdmin | GUI tool for database management |
Stack Builder | Additional tools & extensions |
Command Line Tools | CLI utilities like psql |
Recommended: Install all components
Click Next
πΎ Step 5: Choose Data Directory
This is where PostgreSQL stores database files.
Default location:
C:\\Program Files\\PostgreSQL\\16\\dataClick Next
π Step 6: Set Database Password
You must set a password for the postgres superuser.
Example:
Username: postgres
Password: yourpasswordβ οΈ Important: Remember this password. You will need it to log in.
Click Next
π Step 7: Configure Port
Default PostgreSQL port:
5432Keep the default unless another service is already using this port.
Click Next
π Step 8: Choose Locale
Locale controls language and formatting.
Example:
Default localeClick Next
π Step 9: Install PostgreSQL
Click Install.
<aside> π‘
Skip Stack Builder Setup. Click Cancel
</aside>
The installer will now:
Install PostgreSQL server
Setup database cluster
Install pgAdmin
Configure services
Installation usually takes 2β5 minutes.
π Step 10: Finish Installation
After installation:
Click Finish
PostgreSQL is now installed on your system.
π₯οΈ Step 11: Open pgAdmin
To open pgAdmin:
Start Menu β pgAdmin 4Steps:
pgAdmin will open in your browser
Enter the master password
Expand:
Servers β PostgreSQLEnter the postgres password
Now you can manage databases.
π» Step 12: Test PostgreSQL with Command Line
Open Command Prompt and run:
psql -U postgresEnter password.
If successful, you will see:
postgres=#Example commands:
SELECT version();Create database:
CREATE DATABASE testdb;List databases:
\\lExit:
\\qπ PostgreSQL Important Paths (Windows)
Item | Location |
|---|---|
PostgreSQL Install |
|
Data Folder |
|
psql CLI |
|
β‘ Useful PostgreSQL Commands
Command | Description |
|---|---|
| Connect to database |
| List databases |
| Connect database |
| List tables |
| Quit psql |