All Tech Guides

Tech Guide

Install PostgreSQL and pgAdmin

An introduction to PostgreSQL, how to install it for development on Windows, macOS, and Linux, and a beginner example using psql and pgAdmin.

Databases Beginner Updated October 2026

Disclaimer & Important Cautions

These Tech Guides and instructions are provided in good faith as a general educational guide. Technology changes over time, and settings, software versions, installation steps, and security practices may vary by system.

I cannot guarantee that these steps will work in every environment, and I am not responsible for data loss, configuration problems, system errors, security issues, downtime, or other problems that may result from following this guide.

  • Download PostgreSQL only from postgresql.org or the installers it links to, or from your operating system's package manager.
  • Use administrator privileges carefully when installing software.
  • Use a strong password for the postgres superuser and store it securely. It can be difficult to reset later.
  • Keep the default local-only network settings on a development computer; don't open the database port to the internet.
  • When in doubt, consult official documentation or a qualified technician.

Overview

PostgreSQL (often just Postgres) is a powerful, free, open-source relational database system. It grew out of the POSTGRES project at the University of California, Berkeley in the 1980s and has been developed by a worldwide community for more than 30 years. Postgres is known for closely following the SQL standard, for reliability, and for advanced features such as JSON data, full-text search, and extensions like PostGIS for maps.

The current version is PostgreSQL 18; PostgreSQL 19 is in its final testing and is expected shortly. In this guide you will install PostgreSQL and its graphical tool pgAdmin on your computer, then create and query a database with both the psql command line and pgAdmin.

Main idea: Install the PostgreSQL server, remember the password you set for the postgres user, then connect with psql or pgAdmin to localhost on port 5432.

Is There a "Developer Edition"?

No. Unlike SQL Server, PostgreSQL has only one edition, and it is completely free for any use: learning, development, and production. The PostgreSQL license lets you use, modify, and distribute it at no cost. A "developer setup" simply means installing PostgreSQL on your own computer, which is what this guide does.

OptionWhat it isCost
PostgreSQL (community)The official open-source database. Covered in this guide.Free
EDB installerThe recommended Windows and Mac installer, built by the company EDB. It installs the same free community PostgreSQL plus pgAdmin.Free
Commercial distributions (EDB Postgres Advanced Server and others)Company-supported versions with extra features and paid support.Paid
Cloud services (Amazon RDS, Azure Database for PostgreSQL, Google Cloud SQL, Supabase, Neon)PostgreSQL hosted for you. Many offer free tiers.Free tier to paid

Requirements

  • A 64-bit Windows, macOS, or Linux computer.
  • Administrator privileges to install software.
  • About 1 GB of free disk space.
  • Internet access.

Important Notes

  • During installation you set a password for the postgres superuser. Write it down. You need it every time you connect.
  • PostgreSQL runs in the background as a service and starts automatically with your computer.
  • The default port is 5432. If another program already uses it, the installer suggests a different port; note it if so.
  • Your class may require a specific major version. If so, install that version instead of the newest one.

PostgreSQL Installation Instructions

Choose the tab for your operating system:

Installing PostgreSQL

Click the tab above for your operating system. Allow about 15–20 minutes.

The guide covers these major tasks:

  1. Download the installer.
  2. Choose components (server, pgAdmin, command-line tools).
  3. Set the postgres password.
  4. Keep the default port, 5432.
  5. Finish the installation.
  6. Connect and confirm the version.

Confirm the installation

  1. Open SQL Shell (psql) from the PostgreSQL folder (Windows and Mac EDB installer), or run sudo -u postgres psql on Linux.
  2. SQL Shell asks for Server, Database, Port, and Username. Press Enter at each one to accept the defaults shown in brackets (localhost, postgres, 5432, postgres).
  3. Enter your postgres password. Nothing appears as you type; this is normal.
  4. At the postgres=# prompt, enter:
    SELECT version();
Check yourself: psql prints a line beginning PostgreSQL 18 (or the version you installed).

If You Can't Connect

  • password authentication failed for user "postgres": the password is wrong. It is the one you set in the installer, not your computer's password.
  • Connection refused: the PostgreSQL service isn't running. On Windows, start postgresql-x64-18 in the Services app; on Linux, run sudo systemctl start postgresql.

Beginner Example: A Small Store Database

You will create a database in psql, add two related tables, query them, and then view the same data in pgAdmin.

Step 1: Create a database and connect to it

At the postgres=# prompt in psql:

CREATE DATABASE store;
\c store

Commands that start with a backslash, such as \c (connect), are psql meta-commands, not SQL, and don't need a semicolon. The prompt changes to store=#.

Step 2: Create tables

CREATE TABLE customers (
    customer_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    name        VARCHAR(100) NOT NULL,
    email       VARCHAR(100) UNIQUE,
    city        VARCHAR(50)
);

CREATE TABLE orders (
    order_id    INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    customer_id INT NOT NULL REFERENCES customers(customer_id),
    order_date  DATE NOT NULL DEFAULT CURRENT_DATE,
    total       NUMERIC(10,2) NOT NULL CHECK (total >= 0)
);

GENERATED ALWAYS AS IDENTITY numbers new rows automatically. REFERENCES creates a foreign key, and CHECK rejects negative totals.

Step 3: Insert data

INSERT INTO customers (name, email, city) VALUES
    ('Ana Lopez',    'ana@example.com',   'Salt Lake City'),
    ('Ben Carter',   'ben@example.com',   'Ogden'),
    ('Chloe Nguyen', 'chloe@example.com', 'Salt Lake City');

INSERT INTO orders (customer_id, order_date, total) VALUES
    (1, '2026-09-02', 120.50),
    (1, '2026-10-11',  45.00),
    (2, '2026-10-03', 310.25),
    (3, '2026-10-20',  89.99);

Step 4: Query the data

-- Customers in Salt Lake City
SELECT name, email FROM customers WHERE city = 'Salt Lake City';

-- Orders with customer names
SELECT c.name, o.order_date, o.total
FROM orders AS o
JOIN customers AS c ON c.customer_id = o.customer_id
ORDER BY o.order_date;

-- Total spent per customer
SELECT c.name, COUNT(o.order_id) AS orders, SUM(o.total) AS total_spent
FROM customers AS c
LEFT JOIN orders AS o ON o.customer_id = c.customer_id
GROUP BY c.name
ORDER BY total_spent DESC;

The last query returns:

     name     | orders | total_spent
--------------+--------+-------------
 Ben Carter   |      1 |      310.25
 Ana Lopez    |      2 |      165.50
 Chloe Nguyen |      1 |       89.99
(3 rows)

Step 5: Explore with psql meta-commands

Try each of these. \dt lists the tables, \d orders describes the orders table, \l lists all databases, \? shows all meta-commands, and \q quits psql:

\dt
\d orders
\l
\q

Step 6: View the same data in pgAdmin

  1. Open pgAdmin 4. The first time, it may ask you to set a master password, which protects saved passwords inside pgAdmin. Choose one and remember it.
  2. In the Object Explorer on the left, expand Servers → PostgreSQL 18 and enter your postgres password. Check Save Password if you like.
  3. Expand Databases → store → Schemas → public → Tables. You see customers and orders.
  4. Right-click customers and choose View/Edit Data → All Rows to see the data in a grid.
  5. Select the store database, then choose Tools → Query Tool. Type a query, such as SELECT * FROM orders;, and press F5 (or click the play button) to run it.

Postgres.app users: in pgAdmin, register a server with Host localhost, Port 5432, and your Mac username.

Check yourself: In pgAdmin's Query Tool, SELECT COUNT(*) FROM orders; returns 4, and SELECT SUM(total) FROM orders; returns 565.74.

Common Errors

  • relation "customers" does not exist: you are connected to the wrong database. In psql, run \c store; in pgAdmin, open the Query Tool from the store database.
  • insert or update on table "orders" violates foreign key constraint: the customer_id doesn't exist in customers.
  • The prompt shows store-# instead of store=#: psql is waiting for the rest of a statement. Type ; and press Enter.

Next Steps

Final Notes:
  • PostgreSQL has a single edition that is free for development and production.
  • On Windows and Mac, the EDB installer sets up the server, pgAdmin, and psql together.
  • Remember the postgres password; you need it to connect to localhost:5432.
  • Use psql meta-commands (such as \dt and \c) to explore, and SQL for everything else.
Explore more technology resources

Return to the complete collection of installation and configuration guides.

Browse All Tech Guides