Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sk3pt1c

macrumors 6502a
Original poster
Nov 29, 2005
918
6
a simulacrum
i've installed postgresql on my powerbook to do university work at home
worked fine yesterday
today i type psql to get in and i get this:

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

what is this?
 

mwpeters8182

macrumors 6502
Apr 16, 2003
411
0
Boston, MA
I'm not familiar with postgresql, as I use mysql for my DB work. Do you have to tell it to connect to localhost if the db is on your system?

Like:
psql -h localhost?
 

ChrisA

macrumors G5
Jan 5, 2006
12,904
2,143
Redondo Beach, California
How is the server being started?

sk3pt1c said:
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"?

what is this?

The most likely case is exactly what the message says. How is the server started? Did it start? Read the log file or use "ps", "top" or "activity monitor" to verify that the postgres process is running

There are two ways to connect to a psql client to a the server. (1) as above, using a UNIX domain socket which shows up in the file system and (2) by using a TCP/IP port. The first method only works if the client and server re running on the same machine. Command line switches and an environment variable determine the connection method. I assume you'd want to use (1) for a development on a notebook computer.

So if the server did start, make sure it is usig the UNIX domain socket connection method

The postgres man pages are very good. Read "man postgres" for options on starting the server.
 

lexfuzo

macrumors 6502
Mar 15, 2005
262
0
The heart of Europe
mwpeters8182 said:
I'm not familiar with postgresql, as I use mysql for my DB work. Do you have to tell it to connect to localhost if the db is on your system?
Like:
psql -h localhost?
No, psql assumes local connection (UNIX socket type) if no argument is given.
 

sk3pt1c

macrumors 6502a
Original poster
Nov 29, 2005
918
6
a simulacrum
it's on the same machine
this is what i get when trying postgres and psql

Last login: Wed Jan 25 11:32:54 on ttyp1
Welcome to Darwin!
sk3pt1c says: sql
Password:
sk3pt1c-powerbook:~ postgres$ 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.
sk3pt1c-powerbook:~ postgres$ psql
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've installed postgres according to the guidelines on that developers page and it worked fine yesterday.i also tried aborting terminal and reopening it to see if it works and it did.it's the switching off that's affected it i guess.
the sql command is an alias i've set in my .profile for
su -l postgres
then i just typed psql and got in the psql terminal basically
it doesn't do it now and i don't know how
i've also added a path to the psql commands on my .profile so it shouldn't be that either

any ideas?
 

ChrisA

macrumors G5
Jan 5, 2006
12,904
2,143
Redondo Beach, California
It s SERVER problem, not a psql client problem

Is the SERVER running?

Is it configured to start automatically when the machine boots? If not you will have to start it again by hand each time the after you power up.

is PDDATA set automatically at login or in your sql alias?

It "worked fine" yesterday because the instructions had you start the PostgreSQL server manualy, by hand. The instructions go on to suggest that you set up your computer to start it automatically at boot. Did you do this?


sk3pt1c said:
it's on the same machine
this is what i get when trying postgres and psql

Last login: Wed Jan 25 11:32:54 on ttyp1
Welcome to Darwin!
sk3pt1c says: sql
Password:
sk3pt1c-powerbook:~ postgres$ 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.
sk3pt1c-powerbook:~ postgres$ psql
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've installed postgres according to the guidelines on that developers page and it worked fine yesterday.i also tried aborting terminal and reopening it to see if it works and it did.it's the switching off that's affected it i guess.
the sql command is an alias i've set in my .profile for
su -l postgres
then i just typed psql and got in the psql terminal basically
it doesn't do it now and i don't know how
i've also added a path to the psql commands on my .profile so it shouldn't be that either

any ideas?
 

sk3pt1c

macrumors 6502a
Original poster
Nov 29, 2005
918
6
a simulacrum
i did do it as the instructions say,that's why i'm puzzled

i'd pick mySQL too but that's what we're gonna be working with at uni

when i finished the installation i exited the terminal and opened it again and it worked fine

dunno what's going on...
 

bousozoku

Moderator emeritus
Jun 25, 2002
16,120
2,397
Lard
sk3pt1c said:
i did do it as the instructions say,that's why i'm puzzled

i'd pick mySQL too but that's what we're gonna be working with at uni

when i finished the installation i exited the terminal and opened it again and it worked fine

dunno what's going on...

It sounds to me as if you haven't installed the engine to be automatically started with the system.
 

sk3pt1c

macrumors 6502a
Original poster
Nov 29, 2005
918
6
a simulacrum
ok,you guys were right, i just figured it out

i have to type this every time i want to start the server:

/usr/local/pgsql/bin/pg_ctl -D /Users/ioannisaliazis/postgreSQL/postgres/data -l logfile start

the thing is since i am already in postgres i can't use an alias from my .profile file, right?

is there any way i can set an alias for it or have it run on its own somehow when i enter postgres??
 

lexfuzo

macrumors 6502
Mar 15, 2005
262
0
The heart of Europe
sk3pt1c said:
i have to type this every time i want to start the server:

/usr/local/pgsql/bin/pg_ctl -D /Users/ioannisaliazis/postgreSQL/postgres/data -l logfile start

is there any way i can set an alias for it or have it run on its own somehow when i enter postgres??

Sure there are some ways:
a) You don't have to type it, use the shell history in Terminal.
b) put the line in the file '/etc/rc.local'. This will start the server on system startup
c) read this if you want to dig deeper: http://developer.apple.com/macosx/launchd.html
d) there should be a possibility using the StartupItems-concept, too.
 

sk3pt1c

macrumors 6502a
Original poster
Nov 29, 2005
918
6
a simulacrum
ok,here's what i think happens

i have to first get into postgres and then run this command to start psql

so it doesn't work if i just put it in "profile" in /etc or .profile in my user space

also,aliases don't work inside postrgres so i can't alias it either

i tried the "new command" option from the terminal but that tries to run the new command in a new shell so that doesn't help much

any ideas?
 

lexfuzo

macrumors 6502
Mar 15, 2005
262
0
The heart of Europe
sk3pt1c said:
i have to first get into postgres and then run this command to start psql
No.
First, you (actually, the user 'postgres' should do it) start the PostgreSQL database server (often called 'postmaster') using `pg_ctl`.
Then you use a client program, `psql` to connect to the server. At this point you may say that you "are in postgres".
Server and client, postmaster and psql are different and independent.
 

sk3pt1c

macrumors 6502a
Original poster
Nov 29, 2005
918
6
a simulacrum
in any case i can't start the postmaster or server or whatever it's called before i do su -l postgres and type my password so there's no use in me adding it as a startup thingy
i'll just have to type that long command in every time
thanks though
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.