I am trying to install postgresql on a Yosemite based osX to work with Rails. I tried different things in vain : - brew. - postgre.app - the dmg downloaded directly from the postgresql site.
When I type which psql in a cli I have this:
psql is /usr/local/bin/psql
psql is /usr/local/bin/psql
psql is /usr/local/Cellar/postgresql/9.5.0/bin/psql
psql is /usr/local/bin/psql
If I launch foreman start I have this error:
10:54:47 worker.1 | Is the server running locally and accepting
10:54:47 worker.1 | connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
And if I type psql I have this error too:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Installing postgresql using macports works for me. You can download the installer and open a Terminal-window. Edit your .bashrc if you use bash, I use zsh so I edited .zshrc but the line is the same:
export PATH=/usr/local/bin:/opt/local/bin:/opt/local/sbin:/opt/local/lib/postgresql94/bin:$PATH
Close and open a new Terminal-window and type
sudo port selfupdate
and it will download all available macports-packages. When it is done you can install postgresql with
sudo port install postgresql94-server
Change your path to match the version of postgresql you are using, mine is ver. 9.4. Ver. 9.5 is also available.
Make postgreql start when your machine boots by reading this thread. This also explains how to initialize your database.
You can add your username to postgresql so it can create databases. This can be convenient for testing etc. while developing.
PGUSER=postgres createuser your-username
Macport puts everything it installs in /opt, the db and config-files in /opt/local/var/db/postgresql94. Other configuration-files usually goes into /opt/local/etc.