Postgres cannot start on lion due to missing server configuration file
I am trying to setup pg on a relatively clean lion install and it's not being successful.
First I successfully installed homebrew, and installed postgresql without any errors.
Then I tried to run a rails app, got an error. Tried running this script: http://nextmarvel.net/blog/2011/09/brew-install-postgresql-on-os-x-lion/
in order to hide the default system postgres install, but now I am getting 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 "/tmp/.s.PGSQL.5432"?
When I try to run the postgres
script in the bin directory I get the following error:
larson:~ larson$ /usr/local/Cellar/postgresql/9.1.3/bin/postgres ; exit;
postgres does not know where to find the server configuration file.
You must specify the --config-file or -D invocation option or set the PGDATA environment variable.
logout
It's clear that postgres cannot start because it is not configured correctly. Does anybody have any advice on the proper way to configure it so it starts?
Blindly running homebrew scripts with no idea what they're doing doesn't solve problems - it CREATES them. End Rant.
We don't know what the error you had before was, but now you apparently don't have a database cluster configured.
You need to properly set up your Postgres cluster (see the Postgres manual), and/or tell postgres where the database cluster lives when you start it (that's that bit about You must specify the --config-file or -D invocation option or set the PGDATA environment variable.
from the error message). Section 17.3 of the manual talks about this.
Running brew info postgres
gives you basics to get things going. For example:
If this is your first install, create a database with:
initdb /usr/local/var/postgres -E utf8
Or to restart the database server:
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist