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

I used Fink to install postgresql on os x. when i try to start psql, i get:

psql: 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"?

I have never installed postgresql before so I am not really sure where to look. Have any suggestions?

share|improve this question
    
+1 for just asking the question. I've been thinking of using PostgreSQL on my mac. –  osij2is Aug 4 '09 at 19:09
    
+1 for just mentioning PostgreSQL, my database of choice. –  Avery Payne Aug 4 '09 at 19:41

4 Answers 4

up vote 3 down vote accepted

That means the PostgreSQL daemon is not running. You'll want to find where the daemon is installed. By default, it should be installed in /usr/local/pgsql. If it's there, inspect to see if there is a /usr/local/pgsql/data directory. If there is not run the following:

/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data

then, if successful, run

/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data start

And that should get you on the right track.

share|improve this answer
    
i get an error on initDB. "fixing permissions on existing directory /Library/PostgreSQL/8.4/data ... initdb: could not change permissions of directory "/Library/PostgreSQL/8.4/data": Operation not permitted" ....looking into it. let me know if you know how to fix this. thanks –  Tony Jul 21 '09 at 5:36
    
So most likely you're trying to execute the command as your user but PostgreSQL is already setup with a different user. From this i would guess you can: ls -al /Library/PostgreSQL/8.4/data to find the user who owns it and then do a sudo su username -c 'pg_ctl -D /Library/PostgreSQL/8.4/data start' –  Gavin M. Roy Jul 21 '09 at 18:13

It seems to me, you're trying to run PostgresSQL under your current user-account. I don't know the fink-properties for PostgreSQL, but the associated daemons are supposed to run under a dedicated user-account (lets say postgres for example).

First identify the data-directory, in which PostgresSQL stores it's data and configuration files exist. Your error messages seems to say this may be "/Library/PostgreSQL/8.4/data". This directory should belong already to the postgres-user and have rwx-privileges for him. I guess Fink has already created it, so check out the install-logs.

Look inside this directory (you may need to su/sudo because you may not have sufficient privileges to do so with your console user). If there are some files, eg. postgresql.conf, a bunch of pg_* and some other files, all belonging to postgres, the data directory seems to be allright, otherwise invoke the following (replace the binary-path, postgres-user and the data path with your system-values, see man initdb for more options):

sudo -u postgres /usr/local/pgsql/bin/initdb  -D /Library/PostgreSQL/8.4/data

It's important to sudo as the postgres user here, because the user-account the postgres deamons runs as will have to have the sufficients access-rights.

Also, you will have to start the deamon with the the sudo (this should later be handled by a lauchctl-entry, or something similar), so:

sudo -u postgres /usr/local/pgsql/bin/pg_ctl -D /Library/PostgreSQL/8.4/data

You can always re-create the data-directory, but be sure to make a backup and do not overwrite it when postgres is still running.

share|improve this answer

You can check that Postgresql is running and listening with:

lsof -i |grep LISTEN

share|improve this answer

It sounds as though you don't have the server started, and possibly haven't run initdb

If you have more trouble, though, the easiest (and recommended by postgresql) way to install postgresql on Mac OS X is via the GUI installer provided by EnterpriseDB. It even handles installing multiple versions quite nicely.

share|improve this answer
    
the enterpriseDB installation claimed to fail. said could not initialize the cluster. my guess it that it was a permissions issue when running initDB so i am trying to do that manually now –  Tony Jul 21 '09 at 5:35

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.