0

I'm following this tutorial on how to run Postgres on MAC OS X with MAMP. But I can't seem to add PostgreSQL to my PATH variable. When I run export PATH="/Library/PostgreSQL/11/bin" I get this error:

prompt_context:13: command not found: whoami
prompt_background_jobs:1: command not found: wc
prompt_background_jobs:2: command not found: awk

Here's exactly what I did:

  • I downloaded PostgreSQL 11.2 from Enterprise DB
  • I installed it using the installer:
    • username: postgres
    • password: postgres
    • port: 5433

The PostgreSQL folder can now be found here: /Library/PostgreSQL. Inside there's a folder called 11. Inside /Library/PostgreSQL/11 I can see the bin folder and data folder.

There's another folder inside my Applications folder called PostgreSQL 11. Here I can see a Documentation folder and some other programs I believe:

  • Application Stack Builder
  • pgAdmin 4
  • Reload Configuration
  • SQL Shell (psql)

The following error appears when I ignore setting the PATH variable and run su postgres:

su: Sorry

or sudo postgres:

"root" execution of the PostgreSQL server is not permitted.
The server must be started under an unprivileged user ID to prevent
possible system security compromise. See the documentation for
more information on how to properly start the server

Also, running psql gives me this error, because PostgreSQL is not included in my environmental variables:

psql: could not connect to server: No such file or directory
   Is the server running locally and accepting
   connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

Note: this error asks if the server is accepting Unix domain socket with a port 5432, while I installed PostgreSQL on port 5433, what's up with that? Moving to /Library/PostgreSQL/11/bin with cd and running sudo ./psql (should run the Unix Executable file psql) gives me the same error.


Resources that didn't help me any further:

Derk Jan Speelman
  • 7,870
  • 2
  • 24
  • 43

1 Answers1

1

When you run export PATH="/Library/PostgreSQL/11/bin" you are telling the system that all the commands you need are in that single directory. Since you also need standard system utilities like wc you also need to include the directories where they reside in your PATH. Normally you would do this to simply add the postgres directories to the list of directories searched for commands:

export PATH="/Library/PostgreSQL/11/bin:$PATH"
Kurtis Rader
  • 5,242
  • 9
  • 14