I have installed PostgreSQL using the 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 newly created in /Users/Dhruv to add the line source /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
and various other methods I was able to set up something using some sort of password prompt. I know this later because using sudo -u postgres /Library/PostgreSQL/9.3/bin/createuser
I got
createuser: creation of new role failed: ERROR: role "postgres" already exists
Running then initdb -D /Library/PostgreSQL/9.3/data I get
-bash: initdb: command not found.
Similiarly, if I try the same thing but while connected to postgres, sudo su - postgres
and then initdb -D /Library/PostgreSQL/9.3/data
I get again
-bash: initdb: command not found.
At a loss at what to do. 1) how do I know details of this supposed role "postgres" I created magically and 2) why is initdb not working?
Who are you logged in as?
When you do sudo or su -, it will run init scripts for root, such as .bashrc and .bash_profile.
These may set up difference executable search paths between root, postgres, and you.
Try something like
sudo initdb
, orsu - postgres -c initdb
... whichever user has the paths constructed correctly, so that the path gets set up.You could also duplicate the path/lib creation code in your own environment, but that will break if it is ever changed.