Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to setup postgres on OSX [closed]

I am trying to get postgres setup locally for a rails app on my mac (10.7 Lion).

I installed postgresapp and launched it, I now have an elephant in my status bar telling me that postgres is running.

I can get to it by:

psql -h localhost

But when I simply run psql I get this error:

psql: could not connect to server: Permission denied Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?

I put this:

PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"

In ~/.bashrc and opened a new terminal. But no dice.

When I run which psql I get /usr/bin/psql

Not really sure what to do.. I am still pretty new to unix systems. Should I symlink /usr/bin/psql to /Applications/Postgres.app/Contents/MacOS/bin/psql?

like image 421
JD Isaacks Avatar asked Aug 16 '12 02:08

JD Isaacks


People also ask

What is the best way to install PostgreSQL on Mac?

Step by step guide to set up a local PostgreSQL on Mac using DBngin: Download DBngin from it's download page and install on your Mac just like any other Mac apps. Open DBngin and click on + new server button. Choose PostgreSQL from the driver list, choose your PostgreSQL version, and name you server.

How do I know if PostgreSQL is installed on Mac?

psql -c "SELECT 1" -d {dbname} > /dev/null || postgres -D /usr/local/var/postgres >postgres. log 2>&1 & if you want to check and start postgres in one go (handy for automation scripts).

How do I open port 5432?

Open Windows Firewall Port As an alternative you can go to Control Panel -> Systems and Security -> Windows Firewall -> Allow a program or feature through Windows Firewall -> Advanced Settings -> New Rule: Rule Type: Port. TCP or UDP: TCP. Specific local ports: 5432.


1 Answers

I had a similar issue on my new MacBook Pro running Mountain Lion. I downloaded the PostgresApp and when I fired up rails I received the following error:

`initialize': could not connect to server: No such file or directory (PG::Error)
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?

To fix this I had to explicitly define the host and port in my database.yml file like so:

development:
  adapter: postgresql
  encoding: unicode
  database: my_app_development
  pool: 5
  username: tony
  password: stark    
  host: localhost
  port: 5432
like image 127
Michael Minton Avatar answered Sep 24 '22 11:09

Michael Minton