PostgreSQL Lesson 5 – Installing PostgreSQL | Dataplexa

Installing PostgreSQL

This is where the real learning begins. In this lesson you will download and install PostgreSQL on your computer, get it running, and connect to it for the first time. By the end of this lesson your PostgreSQL is live, ready, and waiting for your first query. Everything from Lesson 8 onwards is hands-on — so get this set up now and practice along with every lesson.

Where to Get PostgreSQL

PostgreSQL is free to download from the official website. Go to postgresql.org/download and choose your operating system — Windows, macOS, or Linux. The current stable version is what you want. Always download from the official site to make sure you get the genuine, secure release.

The recommended installer for beginners on Windows and macOS is the one provided by EDB (EnterpriseDB) — it is the official interactive installer that bundles PostgreSQL, pgAdmin (a visual interface), and the Stack Builder all in one package. It is the easiest way to get everything working in one shot.

Installing on Windows

Go to postgresql.org/download/windows and click Download the installer. Run the downloaded .exe file as Administrator. The installer walks you through everything step by step.

During installation you will be asked to set a password for the postgres superuser — this is the master admin account for your database. Choose something you will remember and write it down. You will need it every time you connect.

Leave the default port as 5432 — this is the standard PostgreSQL port and every tool expects it. Leave the locale as default. Click through to finish. The installer will start the PostgreSQL service automatically and it will run in the background every time your computer starts.

Installing on macOS

The easiest way on macOS is Postgres.app — go to postgresapp.com, download it, drag it to your Applications folder, and open it. Click Initialize and PostgreSQL starts immediately. It sits in your menu bar and you can start and stop it with one click. No terminal commands needed to get started.

Alternatively you can use the EDB installer from the official PostgreSQL site, which works the same way as Windows. Both approaches work perfectly — Postgres.app is just faster and more Mac-native.

Installing on Linux

On Ubuntu or Debian, open your terminal and run these two commands. PostgreSQL will be downloaded, installed, and started automatically.

-- Run these in your Linux terminal (not in PostgreSQL)
sudo apt update
sudo apt install postgresql postgresql-contrib

On Fedora or Red Hat based systems use sudo dnf install postgresql-server instead. After installation, start the service with sudo systemctl start postgresql.

Verifying Your Installation

Once installed, open your terminal (or Command Prompt on Windows) and type the command below. If PostgreSQL is installed correctly, it will print the version number and you are good to go.

-- Check PostgreSQL version in your terminal
psql --version
psql (PostgreSQL) 16.2

Connecting to PostgreSQL for the First Time

psql is the command-line tool that comes with PostgreSQL. It lets you type SQL queries directly and see results instantly. To connect, open your terminal and run the command below. When prompted, enter the password you set during installation.

-- Connect to PostgreSQL as the postgres superuser
psql -U postgres
Password for user postgres:
psql (16.2)
Type "help" for help.

postgres=#

That postgres=# prompt means you are connected and inside PostgreSQL. You can now type SQL. To exit at any time, type \q and press Enter.

Using pgAdmin — The Visual Interface

pgAdmin is a free graphical tool that lets you manage your PostgreSQL databases through a browser-based interface. If you used the EDB installer, pgAdmin was installed alongside PostgreSQL automatically. Search for pgAdmin in your applications and open it.

When pgAdmin opens, you will see a server tree on the left. Right-click Servers, choose Register → Server, give it a name, go to the Connection tab, enter localhost as the host and the postgres password you set, then click Save. You are now connected visually.

pgAdmin has a Query Tool — click on any database, then go to Tools → Query Tool. This is where you will write and run SQL queries with a visual interface. You can use either psql or pgAdmin throughout this course — both work perfectly and we will show examples that work in both.

The Course Dataset — Download It Now

Starting from Lesson 8, every lesson in this course uses a real dataset so you can practice every query, every concept, and every technique on actual data — not just made-up examples. The dataset is a realistic online store database called Dataplexa Store with five tables: customers, products, orders, order_items, and employees. It contains hundreds of rows of real-looking data covering customers from across the US, product catalogue with prices and categories, orders with dates and statuses, and employee records.

Download the dataset file below. It is a .sql file — a plain text file containing all the SQL commands needed to create the tables and load all the data into your PostgreSQL database. You will learn exactly how to load it in Lesson 8 when we cover creating databases and schemas. For now just download it and keep it ready.

📦 Dataplexa Store — Course Dataset

dataplexa-store-dataset.sql  ·  5 tables  ·  customers, products, orders, order_items, employees

⬇ Download Dataset

Quick Reference — Essential psql Commands

Once you are inside psql, these commands will be your most-used tools. They are not SQL — they are psql-specific shortcuts that start with a backslash.

Command What It Does
\q Quit psql and return to terminal
\l List all databases
\c dbname Connect to a specific database
\dt List all tables in current database
\d tablename Show structure of a table
\du List all users and roles
\timing Toggle query execution time display
\? Show all available psql commands

Lesson Summary

Step What to Do
Download postgresql.org/download — choose your OS
Install Run installer, set postgres password, keep port 5432
Verify Run psql --version in terminal
Connect via CLI Run psql -U postgres and enter password
Connect visually Open pgAdmin, register server, use Query Tool
Default port 5432 — never change this unless you have a specific reason
Course dataset Download dataplexa-store-dataset.sql — needed from Lesson 8

🧪 Practice Questions

Answer based on what you learned in this lesson.

1. What is the default port number PostgreSQL listens on?




2. What is the name of the default superuser account created during PostgreSQL installation?




3. What psql command do you type to exit and return to the terminal?




4. Which psql command lists all tables in the currently connected database?




5. What terminal command confirms that PostgreSQL was installed successfully?



🎯 Quiz — Test Your Understanding

Q1. Which command connects you to PostgreSQL as the superuser from the terminal?







Q2. What is the recommended quick-install option for PostgreSQL on macOS?







Q3. What is pgAdmin?







Q4. Which psql command lists all available databases?







Q5. From which lesson will the course dataset be actively used for practice?






Next up: How PostgreSQL works under the hood — its architecture explained simply.