Chapter 2: Install Introduction
Install Introduction
This is basically the “How to get PostgreSQL running on your machine for the first time” lecture — the very first practical step after understanding what Postgres is.
I’m going to explain it like we’re sitting side-by-side in Hyderabad (February 13, 2026, 5:51 PM IST right now 😄), going through the most common & beginner-friendly ways in 2026.
Current reality check (as of today):
- Latest stable major version → PostgreSQL 18
- Latest patch release → 18.2 (released February 12, 2026 — yesterday!)
- We’ll install 18.2 (or whatever 18.x is current when you read this)
There are four popular ways to install Postgres in 2026:
- Native installer (Windows / macOS) — easiest for most students
- Package manager (Linux — Ubuntu/Debian/Fedora)
- Docker — becoming the #1 choice for developers & learners in 2025–2026
- Cloud free tier (Neon, Supabase, Railway) — zero install, but we’ll focus on local first
Let’s go step-by-step, with real commands & screenshots-in-text style.
Option 1: Windows 10/11 (most common for many Indian students)
Download from official trusted source → https://www.postgresql.org/download/windows/ → Redirects to EDB installer
Step-by-step (2026 EDB installer for PostgreSQL 18.2):
- Go to the link above → Choose Windows x86-64 → Download PostgreSQL 18 installer (~300–350 MB).
- Double-click the .exe file (run as administrator if prompted).
- Welcome screen → Next
- Installation Directory → keep default C:\Program Files\PostgreSQL\18 → Next
- Select Components → keep defaults (PostgreSQL Server + pgAdmin 4 + Command Line Tools) → Next
- Data Directory → keep default C:\Program Files\PostgreSQL\18\data → Next
- Password for superuser postgres → choose something strong like MyHyd2026!pg (remember it!)
- Port → default 5432 (don’t change unless you know why) → Next
- Locale → default or [Default locale] → Next
- Ready to install → Next → install (takes 2–5 minutes)
- Finish → uncheck “Launch Stack Builder” (we don’t need it now) → Finish
After install — very important Windows PATH step (many beginners miss this)
- Search “Environment Variables” in Windows search
- Edit the System variable called Path
- Add new entry: C:\Program Files\PostgreSQL\18\bin
- OK → OK → restart any open Command Prompt / PowerShell
Test it works:
Open Command Prompt (cmd) or PowerShell:
|
0 1 2 3 4 5 6 7 8 9 10 11 |
psql --version # should show → psql (PostgreSQL) 18.2 psql -U postgres # enter the password you set # you should see → postgres=# |
Type \q to exit.
Congratulations — you have a local PostgreSQL 18.2 running!
pgAdmin 4 is also installed — search for “pgAdmin 4” in start menu → connect to server localhost:5432 with user postgres.
Option 2: macOS (very clean with Homebrew or Postgres.app)
Easiest → Postgres.app
- Download from site → drag to Applications folder
- Open Postgres.app → it auto-starts server
- Click elephant icon in menu bar → “Initialize” if first time
- Done! It adds psql to PATH automatically.
Alternative — Homebrew (if you already use brew):
|
0 1 2 3 4 5 6 7 |
brew install postgresql@18 brew services start postgresql@18 |
Test: psql postgres
Option 3: Ubuntu 24.04 / 22.04 Linux (very popular in dev community)
Official PGDG repo method (gets you latest 18.2):
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# 1. Add PostgreSQL repo sudo apt update sudo apt install -y curl ca-certificates sudo install -d /usr/share/postgresql-common/pgdg sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc sudo sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' # 2. Install PostgreSQL 18 sudo apt update sudo apt install -y postgresql-18 # 3. It auto-starts. Check status sudo systemctl status postgresql@18-main # 4. Switch to postgres user & enter psql sudo -u postgres psql |
Default: no password for local postgres user (peer authentication).
You can set password later:
|
0 1 2 3 4 5 6 |
\password postgres |
Option 4: Docker — my personal recommendation for 2026 learners
Why Docker? Same setup on Windows/macOS/Linux, no pollution of your machine, easy delete/recreate.
Prerequisites: Install Docker Desktop — free for personal use.
One-command magic:
|
0 1 2 3 4 5 6 7 8 9 10 |
docker run --name my-postgres \ -e POSTGRES_PASSWORD=MyHyd2026!pg \ -d -p 5432:5432 \ -v pgdata:/var/lib/postgresql/data \ postgres:18 |
Explanation:
- -e POSTGRES_PASSWORD=… → sets superuser password
- -p 5432:5432 → exposes Postgres port to your laptop
- -v pgdata:… → saves data even if container stops
- postgres:18 → pulls official image with latest 18.x (18.2 right now)
Test:
|
0 1 2 3 4 5 6 7 8 |
# From your terminal psql -h localhost -U postgres -p 5432 # enter password → connected! |
Or use pgAdmin / DBeaver → host=localhost, port=5432, user=postgres.
Stop / start later:
|
0 1 2 3 4 5 6 7 |
docker stop my-postgres docker start my-postgres |
Quick Summary Table — Choose Your Way (2026)
| Your OS / Preference | Recommended Method | Time to first psql | Difficulty |
|---|---|---|---|
| Windows beginner | EDB Graphical Installer | 5–10 min | ★☆☆☆☆ |
| macOS | Postgres.app | 2–3 min | ★☆☆☆☆ |
| Linux (Ubuntu/Fedora) | Official apt/yum repo | 5 min | ★★☆☆☆ |
| Any OS — clean & modern | Docker | 3–5 min | ★★☆☆☆ |
| Zero install (just learn) | Neon.tech / Supabase free | 1 min (browser) | ★☆☆☆☆ |
Your first “It works!” moment
After any method, run this in psql:
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
SELECT version(); -- Should show → PostgreSQL 18.2 on x86_64-pc-windows-msvc ... or similar CREATE DATABASE my_first_db; \c my_first_db CREATE TABLE hello (message TEXT); INSERT INTO hello VALUES ('Hello from Hyderabad 2026!'); SELECT * FROM hello; |
If you see the row → you’re officially a PostgreSQL user now! 🎉
Next?
Tell me:
- Stuck on any step? (send error)
- Want to install pgAdmin 4 / DBeaver GUI?
- How to create first user/database/schema?
- Or jump to backup / restore basics?
Guru mode still ON — your turn! 🚀
