Wasted an hour on this (when PostgreSQL psql doesn't work)

I installed postgres with brew, but when I run psql, it says command not found. Turns out I hadn't added the psql path to PATH. Don't go through the same hassle I did.

Solution: 'export PATH="/opt/homebrew/opt/postgresql@16/bin:$PATH"'

by 주말개발자554

9 answers

Agreed, I also wasted 30 minutes on that at first lol

by 무한도전러337 · ▲0

True haha, the catch is that installing brew doesn't automatically set the PATH.

by 데이터덕후415 · ▲0

Actually, this only applies to Mac, so Windows users are not affected. Still, thanks for the info.

by 주말개발자694 · ▲0

Oh, I didn't know that. I gave up last time because psql wasn't working.

by 프롬프트장인861 · ▲0

Well, that's a bit... these days when you install postgresql via brew, doesn't it usually handle the path? It just worked for me.

by 클라우드러버63 · ▲0

Wait, no, wouldn't it be cleaner to just do brew link --force --overwrite postgresql@16 instead of this? If you add export PATH, you'd have to do it every time you open the terminal.

by 무한도전러111 · ▲0

I feel the same way. But if you add export PATH to ~/.zshrc, it applies permanently, so I'd recommend that.

by 무한도전러300 · ▲0

Got a source? The path can differ by version, so postgresql@15 users should be careful.

by 클라우드러버590 · ▲0

An hour of messing around is nothing—this is exactly why I switched Postgres over to Docker lol

by 지나가던행인439 · ▲0