Last Updated: February 25, 2016
·
856
· piermariacosina

Config Postgress.app for Terminal

Download and Install Postgres.app ( actual Version 1.0 ) from http://postgresapp.com or https://github.com/mattt/PostgresApp

Running it there should be an elephant icon in the MacOSX top bar, clicking there it should tell you that postgress is running on port 5432

If when you are trying psql your Terminal return no command found
means that you haven't put this PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH" to the wrong place or that the path is incorrect or you haven't event put it anywhere.

If the path is incorrect check that your postgres.app is in the Application folder, and not in a subfolder, in that case add it to the path e.g. "/Applications/Dev/Postgres.app

If you have put it in the wrong place or you haven't put it anywhere, try putting it in the .bashrc but better to the .bash_profile.

Use this
defaults write com.apple.Finder AppleShowAllFiles TRUE
killall Finder
or http://www.macupdate.com/app/mac/26729/houdini
to show hidden file, file starting with . are invisible system files

now navigate to your root user folder, I don't explain the terminal way because you will supposed to know vim or to open a file in your configured editor

So in finder navigate to youruser root or use keyboard shortcut MAIUSC+cmd+H
There you should find .bashrc and .bash_profile try putting the path in one of the two, reboot terminal and try psql again.

if it works try which psql that should print out the path to Application/postgress.app elsewhere you are pointing to an already existing Postgres installation in that case.

If you have Homebrew installed http://mxcl.github.com/homebrew/

brew remove postgresql 

if retrying everything just works you have done the first step, you can configure your Project like Rails to connect to the DB this is an example.

development:
   adapter: postgresql
   encoding: unicode
   database: first_doers_app_development
   pool: 5
   username: eleonoragiammello
   host: localhost
   socket: /var/pgsql_socket

NOTE the last 2 lines prevent this king of error could not connect to server: No such file or directory it can happen because Rails don check localhost by default for postgres db, the second line specify the socket.