问题
I have been having a lot of trouble installing Postgresql on my computer.
I have a Rails app that I deploy to Heroku and want to use Postgresql on my local machine. Before I downloaded Postgres.app but never really used it and recently uninstalled it thinking it may be causing some problems.
I install Postgres and every time I run rake db:create:all, I get the following error:
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've Googled and tried a bunch of things but have not been able to figure it out and thought I might finally have to get some personal help.
When running which psql I get:
/usr/local/bin/psql
I've tried uninstalling Postgres, uninstalling pg and re-installing it but nothing has been able to work.
Any insight here? Thank you.
回答1:
IF you are installing it with homebrew did you install the launch daemon so that the server starts up?
look at brew info postgresql
you will need to init the db
initdb /usr/local/var/postgres -E utf8
then start the server
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
Then you should be able to create your databases, and use it locally. If you are going to be using it you should follow the directions listed in brew for starting and stopping it automatically..
回答2:
Try this
psql -U rails -d myapp_development -h localhost
or
psql -U rails -d myapp_development -h 127.0.0.1
For more help see : Can not connect to local PostgreSQL
回答3:
I have the exactly same problem, try this.
sudo sysctl -w kern.sysv.shmall=65536
sudo sysctl -w kern.sysv.shmmax=16777216
More details here.
来源:https://stackoverflow.com/questions/13538593/installing-postgresql-with-homebrew-and-rails-on-mountain-lion