PostgreSQL Installation

PostgreSQL Tutorial

PostgreSQL Getting Started / Installation

PostgreSQL can be installed on Windows, Linux, and macOS. Below is a beginner-friendly step-by-step guide to get you started.


1️⃣ Check System Requirements

  • OS: Windows / Linux / macOS

  • Disk Space: ~200 MB (more for data)

  • RAM: Minimum 1 GB (recommended 2 GB+)


2️⃣ Install PostgreSQL

 Windows Installation

PostgreSQL Windows Installation
  1. Visit the official PostgreSQL website
    👉 https://www.postgresql.org/download/windows/

  2. Download the EnterpriseDB installer

  3. Run the installer and select:

    • PostgreSQL Server

    • pgAdmin 4

    • Command Line Tools

  4. Set:

    • Superuser password (important)

    • Default port: 5432

  5. Finish installation

✅ pgAdmin will open automatically after installation.


🐧 Linux Installation (Ubuntu/Debian)

Linux Installation
sudo apt update
sudo apt install postgresql postgresql-contrib

Start and enable PostgreSQL:

sudo systemctl start postgresql
sudo systemctl enable postgresql

Check version:

psql --version

🍎 macOS Installation

macOS Installation

Option 1: Using Homebrew

brew install postgresql
brew services start postgresql

Option 2: Postgres.app


3️⃣ Access PostgreSQL

Using Command Line (psql)

psql -U postgres

Linux:

sudo -u postgres psql

Exit:

\q

Using pgAdmin (GUI Tool)

pgAdmin

Steps:

  1. Open pgAdmin 4

  2. Create Server → Register

  3. Enter:

    • Host: localhost

    • Port: 5432

    • Username: postgres

    • Password: (set during install)


4️⃣ Create Your First Database

CREATE DATABASE testdb;

Connect to database:

\c testdb

5️⃣ Create Your First Table

Insert data:


View data:


6️⃣ Basic PostgreSQL Commands

Command Description
\l List databases
\dt List tables
\d tablename Describe table
\c dbname Connect database
\q Quit

7️⃣ Common Beginner Issues & Fixes

 1.psql not recognized
 2.Add PostgreSQL bin folder to PATH

 3.Password authentication failed
 4. Reset postgres password or check pg_hba.conf

 5.Port 5432 already in use
 6.Change port during installation


You may also like...