Reputation: 398
I have installed postgres in Mac using command
brew install [email protected]
and is successfully installed
brew services start [email protected]
is successful also
==> Successfully started [email protected] (label: [email protected])
But when I tried to access Postgres from my Mac terminal psql [email protected]
it prompt me weird error
-bash: /usr/local/bin/psql: No such file or directory
Am I doing something wrong, how to open psql from my terminal
Why there is no psql file in my /usr/local/bin
Upvotes: 4
Views: 12733
Reputation: 61
The accepted answer is incorrect.
If you install [email protected] via Homebrew, the right path for the /bin folder is:
/usr/local/Cellar/[email protected]/9.6.15/bin
To connect, just type: psql postgres
If you're curious about the connections details, just type \conninfo
and check it.
Upvotes: 2
Reputation: 213
You must to enabling Postgres command line tools.
If you are using the default terminal, you are going to want to modify the file at
~/.bash_profile
. If you are using something like Oh My Zsh you are going to want to modify the file ~/.zshrc
.
To edit this file you likely need to open it via the terminal, so open your terminal and type open ~/.bash_profile
. You can replace the word open with subl or whatever text editor you prefer.
Once your zbash_profile
or .zshrc
file is open, add the following line to the end of the file:
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin
After that you will need to quit and restart your terminal This is to make sure it reloads with the changes you just made.
Once you have restarted your terminal, try running psql.
psql -U postgres
You should get the following output.
psql (9.6.0)
Type "help" for help.
postgres=#
You can read more on https://www.calhoun.io/how-to-install-postgresql-9-6-on-mac-os-x/
Upvotes: 0