- bash: initdb: command not found

I installed PostgreSQL using EnterpriseDB installation.

I ran sudo ./postgresql-9.3.5-3-osx.app/Contents/MacOS/installbuilder.sh --mode unattended

and then ran open /Applications/TextEdit.app .profile

to edit my .profile file recently created in / Users / Dhruv to add the linesource /Library/PostgreSQL/9.3/pg_env.sh.

Running createuser Dhruv --pwprompt --username=postgres

I got

- bash: createuser: command not found

Then, running unknown-88-1f-a1-1b-c2-ec:9.3 dhruv$ sudo -u postgres /bin/createuser

various other methods as well, I was able to customize something with a kind of password hint. I know this later because using sudo -u postgres /Library/PostgreSQL/9.3/bin/createuser

I got

createuser: failed to create new role: ERROR: postgres role already exists

Running initdb -D /Library/PostgreSQL/9.3/data I get

- bash: initdb: command not found.

Likewise, if I try to do the same, but when connecting to postgres sudo su - postgres

, and then initdb -D /Library/PostgreSQL/9.3/data

, I get again

- bash: initdb: command not found.

Lose what to do. 1) how do I find out the details of this supposed "postgres" role that I have magically created, and 2) why is initdb not working?

+3


source to share


3 answers


As I fixed it, run brew doctor

it and you can see postgresql un der the Warning: this indicates unlinked kegs in your footer. Try to run brew link postgresql

. It will show some of the symbolic links created. Then start init db ...

again.



Hope for this help!

+1


source


Who did you enter as?

When you do sudo or su -, it will run init scripts for root such as .bashrc and .bash_profile.

They can set differential executable search paths between root, postgres, and you.



Try something like sudo initdb

or su - postgres -c initdb

... which user has the correct paths so that the path will be set up.

You can also duplicate the / lib path creation code in your own environment, but that will break if it ever changes.

0


source


The same thing happened to me. I'm new to OS X from Linux, here's what I needed to do. I installed postgres via homebrew and when I did, I noticed that it downloaded whatever it downloaded: / usr / local / Cellar / postgresql / ($ postgres_version) /

When I cd'd into that folder, I saw a directory called bin, so I cd'd and saw initdb right there. So I had to add this to my path so that I could use the command:

$ export PATH = / usr / local / Cellar / postgresql / 9.4.4 / bin: $ PATH

hope it helps you

-1


source







All Articles