The default installation directory on Mac OS for postgresql

/Library/PostgreSQL/15

With version 15 and likely older versions there is a pg_env.sh script in this folder that can be used to set up some environment variables to point to postgresql executables.

/Library/PostgreSQL/15
mike@Michaels-Laptop 15 % cat pg_env.sh
#!/bin/sh
# The script sets environment variables helpful for PostgreSQL

export PATH=/Library/PostgreSQL/15/bin:$PATH
export PGDATA=/Library/PostgreSQL/15/data
export PGDATABASE=postgres
export PGUSER=postgres
export PGPORT=5432
export PGLOCALEDIR=/Library/PostgreSQL/15/share/locale
export MANPATH=$MANPATH:/Library/PostgreSQL/15/share/man

you can invoke this from your default .zprofile by adding the line

echo “. /Library/PostgreSQL/15/pg_env.sh” >> ~/.zprofile

Leave a Comment

Scroll to Top