Documentation: https://www.postgresql.org/docs/
Download: https://www.postgresql.org/download/
Installation log:
$ brew install postgresql@18
✔︎ JSON API cask.jws.json Downloaded 16.9MB/ 16.9MB
✔︎ JSON API formula.jws.json Downloaded 33.2MB/ 33.2MB
Inspect the formula dependency plan before installing with `brew install --ask`.
Enable ask mode by setting `HOMEBREW_ASK=1`.
Hide these hints with `HOMEBREW_NO_ENV_HINTS=1` (see `man brew`).
==> Fetching downloads for: postgresql@18
✔︎ Bottle Manifest postgresql@18 (18.4) Downloaded 30.5KB/ 30.5KB
✔︎ Bottle ca-certificates (2026-05-14) Downloaded 112.1KB/112.1KB
✔︎ Bottle Manifest openssl@3 (3.6.2) Downloaded 12.0KB/ 12.0KB
✔︎ Bottle postgresql@18 (18.4) Downloaded 20.8MB/ 20.8MB
✔︎ Bottle openssl@3 (3.6.2) Downloaded 10.1MB/ 10.1MB
==> Installing dependencies for postgresql@18: ca-certificates and openssl@3
==> Installing postgresql@18 dependency: ca-certificates
==> Pouring ca-certificates--2026-05-14.all.bottle.tar.gz
==> Regenerating CA certificate bundle from keychain, this may take a while...
🍺 /usr/local/Cellar/ca-certificates/2026-05-14: 4 files, 200.9KB
==> Installing postgresql@18 dependency: openssl@3
==> Pouring openssl@3--3.6.2.tahoe.bottle.tar.gz
🍺 /usr/local/Cellar/openssl@3/3.6.2: 7,627 files, 38MB
==> Installing postgresql@18
==> Pouring postgresql@18--18.4.sonoma.bottle.1.tar.gz
==> /usr/local/Cellar/postgresql@18/18.4/bin/initdb --locale=en_US.UTF-8 -E UTF-8 /usr/local/var/postgres
==> Caveats
This formula has created a default database cluster with:
initdb --locale=en_US.UTF-8 -E UTF-8 /usr/local/var/postgresql@18
When uninstalling, some dead symlinks are left behind so you may want to run:
brew cleanup --prune-prefix
To start postgresql@18 now and restart at login:
brew services start postgresql@18
Or, if you don't want/need a background service you can just run:
LC_ALL="en_US.UTF-8" /usr/local/opt/postgresql@18/bin/postgres -D /usr/local/var/postgresql@18
==> Summary
🍺 /usr/local/Cellar/postgresql@18/18.4: 3,871 files, 74.1MB
==> Running `brew cleanup postgresql@18`...
Disable this behaviour by setting `HOMEBREW_NO_INSTALL_CLEANUP=1`.
Hide these hints with `HOMEBREW_NO_ENV_HINTS=1` (see `man brew`).
==> Caveats
==> postgresql@18
This formula has created a default database cluster with:
initdb --locale=en_US.UTF-8 -E UTF-8 /usr/local/var/postgresql@18
When uninstalling, some dead symlinks are left behind so you may want to run:
brew cleanup --prune-prefix
To start postgresql@18 now and restart at login:
brew services start postgresql@18
Or, if you don't want/need a background service you can just run:
LC_ALL="en_US.UTF-8" /usr/local/opt/postgresql@18/bin/postgres -D /usr/local/var/postgresql@18
Operations:
- show services installed via brew: brew services list
- start postgresql: brew services start postgresql@18
- psql postgres
- \?, \dt (show tables), \du (show users), \l (\list : show databases)
- \c (\connect : connect to a database)
- \dn : show schemas
- \dt *.* : show tables in all schemas
- select * from information_schema.sql_features;
- CREATE TABLE users (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL
);
- INSERT INTO users (name) VALUES ('Alice'), ('Bob'), ('Charlie');
- select * from users;
- \d users; (check table structure)