My learning diary

Installing Postgres on macOS

Before this, the last time I installed a Postgres database on my local machine was years ago. I wished I found Sami Korpela’s blog post sooner. It had everything I needed:

# macOS Ventura Terminal

brew install postgresql@15
echo 'export PATH="/opt/homebrew/opt/postgresql@15/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
brew services start postgresql
createuser -s postgres
psql postgres # or psql -U your_username -d your_database

### postgres=# ###

\l # List databases
\du # List roles
\c your_database # Connect to database
\c your_database other_username # Connect to database as other_username
\d # List relations (tables)