Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

-bash: createdb: command not found

I'm using a Mac and I already have installed PostgreSQL in my computer using the dmg provided by PostgreSQL (and not by Postgres.app).

I have installed it because I will go to use it with Django, and for to get the correct functionality with the framework, I had to do the next commands:

export PATH=/Library/PostgreSQL/9.5/bin/:"$PATH”
sudo ln -s /Library/PostgreSQL/9.5/lib/libssl.1.0.0.dylib /usr/lib 
sudo ln -s /Library/PostgreSQL/9.5/lib/libcrypto.1.0.0.dylib /usr/lib

$ sudo mv /usr/lib/libpq.5.dylib /usr/lib/libpq.5.dylib.old  
$ sudo ln -s /Library/PostgreSQL/9.5/lib/libpq.5.dylib /usr/lib

Then I executed the command:

./manage.py migrate

Getting at the terminal a message like this:

enter image description here

And knowing that I needed to create a user "erikb" in PostgreSQL.

I can enter in terminal the command:

sudo su - postgres

To enter to PostgreSQL, but when I wanted to create a DB o a new user, it sent me the next error: -bash: createuser: command not found

enter image description here

Does anyone know which could be the problem?

Regards.

like image 824
Erik Barajas Avatar asked Jun 23 '26 16:06

Erik Barajas


1 Answers

You set the PATH variable in your user account, and then you su'd to a different user. That user does not inherit your environment, including your path.

You need to set the environment for that user, or else use the full path to the createdb command.

export PATH=/Library/PostgreSQL/9.5/bin/:$PATH
createdb erikb
like image 148
Dan Lowe Avatar answered Jun 26 '26 18:06

Dan Lowe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!