Installing PostgreSQL
Objectives
By the end of this lesson, you should be able to:
- Install PostgreSQL on your own machine
- Explain what gets installed alongside the database server itself
💡 Why this matters: Every lesson from here on assumes you have a real PostgreSQL server running on your own machine. This lesson gets one installed.
⚠️ A note on verification: the SQL commands and results used throughout this course were run against a real, live PostgreSQL 18 engine and are exact. The installation steps in this specific lesson are standard, current instructions from postgresql.org, but weren’t executed inside this course’s own tooling. If a step looks different on your system, PostgreSQL’s official documentation for your operating system is the definitive source.
What Gets Installed
Installing PostgreSQL sets up three things at once:
- The PostgreSQL server, the actual program that stores your data and runs queries against it, running quietly in the background.
- psql, the official command-line client for talking to that server (its own lesson, coming up shortly).
- pgAdmin, the official graphical client for talking to that server (also its own lesson, next).
Installing on macOS
Using Homebrew:
brew install postgresql@18
brew services start postgresql@18
brew services start sets PostgreSQL to run in the background automatically, including after a restart.
Installing on Windows
Download the installer from postgresql.org/download, run it, and follow the setup wizard. It installs the server, psql, and pgAdmin together, and sets a password for the default postgres superuser account during setup, keep that password, it’s needed to connect.
Installing on Linux (Debian/Ubuntu-based)
sudo apt update
sudo apt install postgresql postgresql-contrib
This installs the server and command-line tools. On most Linux distributions, pgAdmin is installed separately, either as its own package or downloaded directly from pgadmin.org.
Confirming It’s Running
However you installed it, PostgreSQL should now be running as a background service. The next two lessons connect to it, first with pgAdmin, then with psql, to confirm the install actually worked.
Try It
- Install PostgreSQL following the instructions for your operating system.
- Confirm the installer also gave you
psqland pgAdmin (check your applications list, or runpsql --versionin a terminal). - If you were prompted to set a password for the
postgresuser during installation, write it down somewhere safe, it’s needed in the next two lessons.
Recap
- Installing PostgreSQL sets up the server itself, plus two ways to talk to it:
psql(command line) and pgAdmin (graphical). - Installation steps differ slightly by operating system, but the end result is the same: a running PostgreSQL server, ready to connect to.
Next lesson: connecting to your new PostgreSQL server using pgAdmin, its graphical interface.