Saturday, 18 April 2026

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

  1. Open your browser
  2. Visit the official PostgreSQL download page:
    https://www.postgresql.org/download/windows/
    
  3. Click Download the installer
  4. You will be redirected to the EnterpriseDB page
  5. Download the latest stable version

Step 2: Run the Installer

  1. Double‑click the downloaded .exe file
  2. 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 NextNextFinish

PostgreSQL is now installed on Windows.


Verify Installation on Windows

  1. Open pgAdmin 4
  2. Enter the password you set
  3. 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

sudo apt install postgresql postgresql-contrib

Step 3: Check PostgreSQL Service Status

sudo systemctl status postgresql

If the status shows active (running), PostgreSQL is running.

Step 4: Access PostgreSQL Shell

sudo -u postgres psql

You should see:
postgres=#

Type \q to exit.

PostgreSQL is now installed on Linux.


Installing PostgreSQL on macOS

Method 1: Using Official Installer

  1. Visit:
    https://www.postgresql.org/download/macos/
    
  2. Download the PostgreSQL installer
  3. Open the .dmg file
  4. Follow the installation steps
  5. 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 --version

Example output:

psql (PostgreSQL) 16.x

Connect to PostgreSQL

psql -U postgres

If the PostgreSQL prompt opens, installation is successful.

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

Multithreading in PostgreSQL Using dblink and FDW (Reality vs Myth) First: The Critical Truth (Must Be Clear) You cannot create true mul...