Printing and PDF export are disabled for this content. View it online at Full Stack Learning Simplified.
Install PostgreSQL and Connect
Install PostgreSQL, then connect with the built-in psql command-line client β the fastest way to run SQL and inspect your database.
Install
bash
# macOS (Homebrew)
brew install postgresql@18 && brew services start postgresql@18
# or run it in Docker (no local install)
docker run -e POSTGRES_PASSWORD=secret -p 5432:5432 postgres:18Connect with psql
bash
psql -U postgres # connect as the postgres user
psql postgresql://user:pass@localhost:5432/mydb # a connection stringpsql meta-commands
Inside psql, backslash commands help you explore (they're psql features, not SQL).
| Command | Does |
|---|---|
\l | list databases |
\c mydb | connect to a database |
\dt | list tables |
\d products | describe a table |
\? / \q | help / quit |
Connection basics
Postgres listens on port 5432 by default. A connection needs host, port, database, user, and password β often bundled as a URL (postgresql://user:pass@host:5432/db) that apps and tools accept.
Tip: Prefer a GUI? pgAdmin and DBeaver are popular free tools for browsing tables and running queries visually β but knowing
psql pays off on servers where no GUI is available.Free preview. Sign in and subscribe to unlock all 809 lessons across 25 courses.
Free preview Β· Β© 2026 Full Stack Learning Simplified