8

After su postgres and typing of my password in my macOS terminal, it shows bash-3.2$

What when I type command like createdb, it says:

bash: createdb: command not found

I googled and it says "either PostgreSQL was not installed at all or your shell's search path was not set to include it."

How can I fix this?

3

1 Answer 1

1

Before typing in su postgres type in which createdb which will tell you what the path is for createdb. For example if which returns /usr/local/bin/createdb, you would add that path to your environmental variable $PATH by typing export PATH=$PATH:/usr/local/bin in the command line once you type su postgres. Then you can run createdb.

Alternatively, you can just specify the full path in the command line /usr/local/bin/createdb. If you need to do this often, you can add the line to change the PATH variable in ~/.bash_profile.

Sign up to request clarification or add additional context in comments.

6 Comments

Thx for the help but it says "createdb not found" after I typed "which createdb"
@user3315620 Have you installed postgres? How did you do it, and where was it installed?
I downloaded it from the website and put it(PostgreSQL 9.3) in /Applications
The PostgreSQL 9.3 file consists of Application Stack Builder, Documentation, pgAdmin III, Reload Configuration, SQL shell(psql)
Try (you should install homebrew first):brew install postgresql
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.