5

lawn-128-61-59-74:~ postgres$ createuser -R -P -S -D fhir

After running "brew install postgresql" and running postgres, when running the above command I am getting the following error:

"-bash: createuser: command not found"

luii
  • 319
  • 3
  • 5
  • 16

3 Answers3

7

run:

 sudo find / -name createuser

This will find where the createuser command is located on your machine. Add what you find to your path.

Nathan Hinchey
  • 1,191
  • 9
  • 30
Vao Tsun
  • 47,234
  • 13
  • 100
  • 132
5

This probably means that Postgres is not in your PATH.

Since you installed with Homebrew, your PATH should include

Applications/Postgres.app/Contents/Versions/9.6/bin

You can add this line to your .bash_profile to fix that

export PATH="Applications/Postres.app/Contents/Versions/9.6/bin:$PATH"

(Note: 9.6 is the version -- this may be different for you.)


If you didn't use brew to install Postgres you can use Vao Tsun's answer to find where Postgres is on your machine, and add that to your path instead

Nathan Hinchey
  • 1,191
  • 9
  • 30
  • 1
    You have a typo, should be: `export PATH="/Applications/Postgres.app/Contents/Versions/9.6/bin:$PATH"` Missing a g in postgres. – bbs Sep 03 '18 at 03:52
  • This path is for Postgres installed with Postgres.app. If you installed with Homebrew, it'll look more like `/usr/local/Cellar/postgresql@9.6/9.6.20/bin/`. – tao_oat Jan 08 '21 at 09:41
0

From your console/putty/shell you can connect to PgSQL running:

su - postgres -c "psql"

then you can run/execute yours commands/QUERYS...

CREATE USER synapse;
ALTER USER synapse WITH ENCRYPTED password 'I-love-Stackoverflow.com-xD';
CREATE DATABASE synapse ENCODING 'UTF-8' LC_COLLATE='en_US.UTF-8' LC_CTYPE='en_US.UTF-8' template=template0 OWNER synapse;

if you have some trouble, then first try creating a ROLE:

CREATE ROLE synapse;
DROP ROLE synapse;

and after you can CREATE users...

Regards

Stackoverflow
  • 449
  • 5
  • 13