Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails issues when connection to PostgreSQL database

Attempting to get Rails running with postgresql on mac osx 10.8 to deploy to heroku. I'm new to mac's.

Had lots of trouble just getting PostgrSQL installed so I could have botched up something trying all the potential solutions I could find searching on that subject. Which mainly appeared to be permissions and existing OSX installation. for this issue I'm noticing some things that make me think there is some fundamental directory or version conflict that I'm not sure how to resolve yet. But I could be wrong and it is something else! Any direction is appreciated.

retrieving an error such as this:

$ rake db:create:all
could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?

I'm not sure where and why it's looking for the var directory but ~/var appears to be a link (alias) to /private/var (which has empty pgsql_socket & pgsql_socket_alt directories), /usr/local/var doesn't have pgsql_socket directory but does have a postgres directory. both of those directories my admin user has read & write permission from the finder get info dialog.

The above error shown is followed by a long stack in the gems 1.8 directory and finishes with this:

Couldn't create database for {"pool"=>5, "database"=>"blog_development", "password"=>nil, "username"=>"USERNAME", "encoding"=>"unicode", "adapter"=>"postgresql"}

so checking:

   $ which psql
/usr/bin/psql

i do remember after installing postgresql i did this:

  initdb /usr/local/var/postgres -E utf8

Confirmed:

$ ps aux | grep postgres
username           346   0.0  0.1  2479616   7724   ??  S     3:08PM   0:00.03 /usr/local/bin/postgres -D /usr/local/var/postgres -r /usr/local/var/postgres/server.log

bundle show yields: pg (0.14.1)

$ postgres --version
postgres (PostgreSQL) 9.2.1

echo $PATH does not show any reference to posgresql. this app is in a /Users/USERNAME/SUBDIR/APP.

Andy ideas on where i've messed up and how i can get this stuff up and running? I'd appreciate any direction. I'll keep working through stack overflow and google discussions; although my stupidity may be unique!

Thanks.

like image 276
twinturbotom Avatar asked Oct 07 '12 21:10

twinturbotom


Video Answer


1 Answers

Add

host: localhost

to database.yml

like image 65
twinturbotom Avatar answered Nov 10 '22 00:11

twinturbotom