Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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
ovatsug25=#

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
/usr/local/bin/psql

and which postgres

which postgres
/usr/local/bin/postgres
share|improve this question
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

1 Answer 1

up vote 4 down vote accepted

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

share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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