Script Valley
PostgreSQL: Complete Course
Getting Started with PostgreSQLLesson 1.1

How to install PostgreSQL on Windows, Mac, and Linux

PostgreSQL installation, psql CLI, pgAdmin setup, postgres superuser, initdb, pg_hba.conf basics

Installing PostgreSQL

PostgreSQL ships as a native package on every major OS. Use the official installer or your package manager — do not compile from source unless you have a specific reason.

Windows

Download the EDB installer from postgresql.org. Run it, choose a data directory (default C:\Program Files\PostgreSQL\16\data), set a password for the postgres superuser, and leave the port at 5432.

macOS

brew install postgresql@16
brew services start postgresql@16
psql postgres

Linux (Debian/Ubuntu)

sudo apt update
sudo apt install postgresql postgresql-contrib
sudo systemctl start postgresql
sudo -u postgres psql

Verify the installation

psql --version
# postgresql 16.x

After installation, the postgres OS user and database superuser are created automatically. The server listens on port 5432 by default. pg_hba.conf controls client authentication — on a local dev machine the default trust or md5 method is fine. Once you can run psql -U postgres without an error, your setup is complete.

Up next

What is psql and how to use the psql command line tool

Sign in to track progress