Apple has had a couple changes of the default shell along the way. The core error presented in this question is command not found. I'll advise how to resolve that issue.
First, let's find where we have Postgresql installed:
find / -type f -name psql -print | sort
This locates all files called psql
on your system. This should only report a single entry. Note there may be a lot of errors presented (e.g. find: /private/var/agentx: Permission denied). You may safely ignore those.
For your system, the binary was located here: /opt/local/lib/postgresql91/bin/psql
I use homebrew, so mine is located here: /opt/homebrew/bin/psql
Take the psql off the end. That is the directory. We will use it below.
Open the Terminal.app often located in the Utilities directory of your applications.
Run this command:
open -e .profile ; open -e .cshrc ; open -e .zshrc; open -e .login; open -e .bash_profile
Ignore any errors such as:
The file /Users/risner/.zshrc does not exist.
The file /Users/risner/.login does not exist.
In the open files, you may see lines like "set path =" for .cshrc or .login and "PATH=" for others.
Add the directory path from above to all the path lines, by adding the directory path /opt/local/lib/postgresql91/bin/
. For example, with .cshrc or .login where they are separated by spaces you change:
set path = ($HOME/bin /bin /sbin /usr/bin /usr/sbin /usr/X11R6/bin)
to this:
set path = ($HOME/bin /bin /sbin /usr/bin /usr/sbin /usr/X11R6/bin /opt/local/lib/postgresql91/bin)
For others where they are separated by :, change:
export PATH="~/bin:$PATH"
to
export PATH="~/bin:/opt/local/lib/postgresql91/bin:$PATH"
echo $PATH
andls /opt/local/lib/postgresql91/bin/
. Include the full, exact text of the error message too. – Catchmentpsql
is the client.postgres
is the server, but it's normally started up when your computer starts or manually controlled withpg_ctl
not launched directly. The PostgreSQL tutorial will help explain much of this. – Catchmentalias psql='/Library/PostgreSQL/12/bin/psql'
to .zshrc (or presumably add to .bash_profile). – Dislimn