Install PostgreSQL locally on any major OS to start developing, testing, and running SQL databases on your machine.
Use your platforms native package manager or the official graphical installer. Package managers finish in seconds, keep PostgreSQL updated automatically, and can be scripted.
choco install postgresql --version 16.2
downloads the MSI, installs the server, creates a Windows service, and sets the PATH.Change --version
to pin a release or omit it for the latest.
brew install postgresql@16
installs binaries under /opt/homebrew/opt/postgresql@16
, sets up launchd for autostart, and creates the default superuser matching your macOS login.
sudo apt-get update && sudo apt-get install postgresql-16
adds the server, psql
client, and service unit under systemd
. PostgreSQL starts automatically at boot.
Package managers perform initdb
during install.If you built from source, run initdb -D /usr/local/pgsql/data
then pg_ctl -D /usr/local/pgsql/data -l logfile start
.
Connect with psql -U postgres
(Windows) or psql
(Unix19s peer auth). Run SELECT version();
to confirm the server responds.
1. Change the default postgres
password: \password postgres
in psql
.
2. Open remote access: edit postgresql.conf
(listen_addresses
) and pg_hba.conf
(host lines).
3.Enable autostart: brew services start postgresql@16
or sudo systemctl enable --now postgresql
.
Keep one major version, use separate roles per app, back up with pg_dumpall
, and avoid superuser work in day49day development.
Skipping the PATH update blocks psql
; mixing Homebrew and Postgres.app binaries causes socket conflicts.
.
Windows prompts for a superuser password during setup. Unix-like installs rely on peer authentication, so no password is set until you run \password
inside psql
.
Yes. Change the port in postgresql.conf
for the second cluster and start each service separately. Homebrew names formulas by version to simplify this.
Reverse your package manager command: choco uninstall postgresql
, brew uninstall postgresql@16
, or sudo apt-get remove --purge postgresql*
. Drop the data directory manually if no longer needed.