views:

167

answers:

3

I followed the instructions for setting up postgresql from this site

All seems to go fine until I try:

createuser --superuser myname -U postgres

I get the following exception:

createuser: could not connect to database postgres: 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"?

For the life of me I can't figure out how to resolve this. Any ideas???

A: 

Did you install the postgresql84-server port? If so, did you start the server:

$ sudo port load postgresql84-server

If you did both of those, I've noticed that sometimes the MacPorts daemon handler (daemondo) doesn't start handling requests for PostgreSQL until you restart your machine. (This only happens the first time it is started; subsequent attempts should work fine.)

mipadi
Tried the restart ... did not work. Ran "sudo port load postgresql84-server" ... got "Error: Target org.macports.load returned: org.macports.postgresql84-server: Already loadedError: Status 1 encountered during processing."
wgpubs
+1  A: 

I had to remove the existing postgres user before doing the install.

wgpubs
+1  A: 

Perhaps you moved your postgres data directory after you installed postgres using macports

Find where your launchctl startup script is located.

ps -ef | grep postgres

Outputs

0 54 1 0 0:00.01 ?? 0:00.01 /opt/local/bin/daemondo --label=postgresql84-server --start-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql84-server/postgresql84-server.wrapper start ; --stop-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql84-server/postgresql84-server.wrapper stop ; --restart-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql84-server/postgresql84-server.wrapper restart ; --pid=none

So I edit

sudo vim /opt/local/etc/LaunchDaemons/org.macports.postgresql84-server/postgresql84-server.wrapper

And find the line

Start()  {         
su postgres -c "${PGCTL} -D ${POSTGRESQL84DATA:=/opt/local/var/db/postgresql84/wrong_place}     start -l /opt/local/var/log/postgresql84/postgres.log" 

}

Ahh.. my data directory is in the wrong place. I fix it by changing

/opt/local/var/db/postgresql84/wrong_place

to

/opt/local/var/db/postgresql84/right_place

for both the start and stop command.

surtyaar