How to Install PostgreSQL on Windows,
Linux, and macOS (Step by Step)
Before you start learning PostgreSQL programming, you need PostgreSQL installed on your system.
This guide explains how to install PostgreSQL step by step on:
- Windows
- Linux (Ubuntu)
- macOS
This tutorial is beginner‑friendly and requires no prior database knowledge.
Prerequisites
Before installing PostgreSQL, ensure that:
- You have a computer (Windows, Linux, or macOS)
- You have internet access
- You have administrator access
Installing PostgreSQL on Windows
Step 1: Download PostgreSQL
- Open your browser
- Visit the official PostgreSQL download page:
https://www.postgresql.org/download/windows/ - Click Download the installer
- You will be redirected to the EnterpriseDB page
- Download the latest stable version
Step 2: Run the Installer
- Double‑click the downloaded
.exefile - Click Next to begin installation
Step 3: Choose Installation Directory
- Keep the default directory
- Click Next
Step 4: Select Components
Make sure the following components are selected:
- PostgreSQL Server
- pgAdmin 4
- Command Line Tools
Click Next
Step 5: Set Password
- Enter a password for the postgres user
- Remember this password
Click Next
Step 6: Choose Port Number
- Default port: 5432
- Keep it unchanged
- Click Next
Step 7: Complete Installation
- Click Next → Next → Finish
PostgreSQL is now installed on Windows.
Verify Installation on Windows
- Open pgAdmin 4
- Enter the password you set
- Expand:
Servers → PostgreSQL
If the dashboard appears, installation was successful.
Installing PostgreSQL on Linux (Ubuntu)
Step 1: Update Package List
Open terminal and run:
sudo apt update
Step 2: Install PostgreSQL
Step 3: Check PostgreSQL Service Status
Step 4: Access PostgreSQL Shell
\q to exit.PostgreSQL is now installed on Linux.
Installing PostgreSQL on macOS
Method 1: Using Official Installer
- Visit:
https://www.postgresql.org/download/macos/ - Download the PostgreSQL installer
- Open the
.dmgfile - Follow the installation steps
- Set a password for the postgres user
Method 2: Using Homebrew
If Homebrew is installed:
brew install postgresql
Start PostgreSQL service:
brew services start postgresql
Verify PostgreSQL Installation (All Operating Systems)
Check PostgreSQL Version
psql (PostgreSQL) 16.x
Connect to PostgreSQL
Common Installation Issues
Password Forgotten
- Windows/macOS: Reinstall PostgreSQL
- Linux: Reset password using
psql
Port 5432 Already in Use
- Stop the service using the port
- Or choose a different port during installation
What’s Next?
Now that PostgreSQL is installed, the next step is learning basic SQL commands.
Next article:
Basic SQL Commands in PostgreSQL (SELECT, INSERT, UPDATE, DELETE)
Summary
- PostgreSQL installed successfully
- Installation verified
- Ready to start PostgreSQL programming
You are now ready to begin your PostgreSQL journey.
No comments:
Post a Comment