Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres createdb: command not found Mac OS Terminal [duplicate]

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?

like image 771
user3315620 Avatar asked Nov 11 '22 09:11

user3315620


1 Answers

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.

like image 114
dr jimbob Avatar answered Nov 15 '22 11:11

dr jimbob