I'm running mountain lion and I am getting very different responses when I run the psql or postgres commands.

For the former I get:

> psql

For the latter I get:

> postgres
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.

I installed postgres via homebrew and ran

rm /usr/bin/psql

after doing so.

My main problem is fixed (Rails starts and connects to the db) but I'm not sure where the difference lies between these commands or how that happened. Still trying to figure it out bun in the meantime...I'd appreciate any help.

Their locations

which psql

and which postgres

which postgres
  • 4
    psql is the PostgreSQL interactive client, postgres is the service daemon. What are you trying to accomplish? – jscott Nov 29 '12 at 20:20
  • basically having trouble setting it up, first because of memory settings, then because rails was telling me that it couldn't find the configuration files despite the fact that I had started it. that was all fixed, but i still didn't (and don't) exactly understand what was happening or what i was doing wrong. – ovatsug25 Nov 29 '12 at 20:43

postgres is the server itself, and runs separately from all of the client connections. It is almost never run by hand. Even if you want to start and stop it, this is normally done through pg_ctl or an init script if you installed a postgres package from your distribution. I'm not sure if the OSX version of Postgresql has any special ways of starting the server, but it needs to be started before any clients can connect to it.

psql is the command-line client, that connects to the server and allows you to execute individual queries by hand. No idea why you think you needed to rm it, but not having it is just annoying since without it you'll have to write your own programs to execute commands like "CREATE TABLE" or "CREATE USER".

  • i still have psql, i just think i am now using the homebrew version and not the one by default on the system. if you see the comment right after the question, basically i was having trouble installing and getting it all up and running and was too engrossed in finding a command, which i eventually did by ignoring the "postgres" option. this help, but i think that system version was interfering with the homebrew version, no? what are those commands i'll be missing? – ovatsug25 Nov 29 '12 at 20:47
  • I didn't realize that OSX comes with Postgres now, so if you have the psql executable from homebrew, that should be fine – DerfK Nov 29 '12 at 21:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.