PostgreSQL Installation

PostgreSQL Tutorial

PostgreSQL Getting Started / Installation

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


Check System Requirements

  • OS: Windows / Linux / macOS

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

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


 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


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)


Create Your First Database

CREATE DATABASE testdb;

Connect to database:

\c testdb

Create Your First Table

Insert data:


Basic PostgreSQL Commands

CommandDescription
\lList databases
\dtList tables
\d tablenameDescribe table
\c dbnameConnect database
\qQuit

 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...