Installing PostgreSQL
postgres process listening for connections, plus the psql command-line client to talk to it.Windows
psql, pgAdmin (a graphical admin tool covered later in this series), and Stack Builder, a utility for optionally installing extra drivers and extensions after setup.Download the installer from the official PostgreSQL downloads page
Run it and choose which components to install (keep the defaults if unsure)
Set a password for the default postgres superuser when prompted
Keep the default port, 5432, unless you have a specific reason to change it
Optionally launch Stack Builder at the end to add extensions
macOS
Installing with Homebrew
brew install postgresql@16 brew services start postgresql@16
Linux
Most Linux distributions ship PostgreSQL through their standard package manager.
Debian / Ubuntu (apt)
sudo apt update sudo apt install postgresql postgresql-contrib sudo systemctl enable --now postgresql
Fedora / RHEL (dnf)
sudo dnf install postgresql-server postgresql-contrib sudo postgresql-setup --initdb sudo systemctl enable --now postgresql
Verifying your installation
Whatever platform you used, confirm the client tools were installed correctly by checking the version:
psql --version
postgres along with a matching database superuser of the same name. On Windows, you set the postgres superuser password directly during setup. Either way, you should now be able to connect:psql -U postgres
The quick cross-platform alternative: Docker
If you already use Docker, running PostgreSQL in a container avoids touching your operating system at all, and is trivial to tear down and recreate:
Running PostgreSQL in Docker
docker run --name pg-tutorial \ -e POSTGRES_PASSWORD=mysecretpassword \ -p 5432:5432 \ -d postgres
psql.