Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 25, 2006, 05:29 AM   #1
sk3pt1c
macrumors 6502a
 
Join Date: Nov 2005
Location: a simulacrum
postgreSQL help

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?
__________________
Vi Veri Veniversum Vivus Vici
Macbook Pro 15" Retina
sk3pt1c is offline   0 Reply With Quote
Old Jan 25, 2006, 08:49 AM   #2
lexfuzo
macrumors 6502
 
Join Date: Mar 2005
Location: The heart of Europe
Is the server running?
Did you reboot the computer and not start the postmaster?
__________________
Proud owner of an iBook 12/1.33
Soon upgrading to a MacBook Con
lexfuzo is offline   0 Reply With Quote
Old Jan 25, 2006, 10:09 AM   #3
mwpeters8182
macrumors 6502
 
Join Date: Apr 2003
Location: 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?
__________________
2.0 GHz Aluminum MacBook
iPhone 3G
mwpeters8182 is offline   0 Reply With Quote
Old Jan 25, 2006, 10:34 AM   #4
ChrisA
macrumors G4
 
Join Date: Jan 2006
Location: Redondo Beach, California
How is the server being started?

Quote:
Originally Posted by sk3pt1c

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.
ChrisA is offline   0 Reply With Quote
Old Jan 25, 2006, 11:49 AM   #5
Wince99
macrumors newbie
 
Join Date: Oct 2005
Location: Montreal
Send a message via AIM to Wince99
Quote:
Originally Posted by mwpeters8182
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?
try this link, it explains how to do it :

http://developer.apple.com/internet/.../postgres.html
__________________
Wince99
---------------------------------
Cleaning Windows is an endless task, bugs keep sticking
Wince99 is offline   0 Reply With Quote
Old Jan 25, 2006, 01:23 PM   #6
lexfuzo
macrumors 6502
 
Join Date: Mar 2005
Location: The heart of Europe
Quote:
Originally Posted by mwpeters8182
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.
__________________
Proud owner of an iBook 12/1.33
Soon upgrading to a MacBook Con
lexfuzo is offline   0 Reply With Quote
Old Jan 25, 2006, 01:29 PM   #7
sk3pt1c
Thread Starter
macrumors 6502a
 
Join Date: Nov 2005
Location: 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?
__________________
Vi Veri Veniversum Vivus Vici
Macbook Pro 15" Retina
sk3pt1c is offline   0 Reply With Quote
Old Jan 25, 2006, 01:52 PM   #8
ChrisA
macrumors G4
 
Join Date: Jan 2006
Location: 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?


Quote:
Originally Posted by sk3pt1c
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 is offline   0 Reply With Quote
Old Jan 25, 2006, 04:37 PM   #9
mwpeters8182
macrumors 6502
 
Join Date: Apr 2003
Location: Boston, MA
Quote:
Originally Posted by lexfuzo
No, psql assumes local connection (UNIX socket type) if no argument is given.
Good to know, in case I ever run into that, but I think I'll stick with mysql for my databases.
__________________
2.0 GHz Aluminum MacBook
iPhone 3G
mwpeters8182 is offline   0 Reply With Quote
Old Jan 25, 2006, 06:22 PM   #10
sk3pt1c
Thread Starter
macrumors 6502a
 
Join Date: Nov 2005
Location: 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...
__________________
Vi Veri Veniversum Vivus Vici
Macbook Pro 15" Retina
sk3pt1c is offline   0 Reply With Quote
Old Jan 25, 2006, 06:30 PM   #11
bousozoku
Moderator emeritus
 
Join Date: Jun 2002
Location: Gone but not forgotten.
Quote:
Originally Posted by sk3pt1c
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.
bousozoku is offline   0 Reply With Quote
Old Jan 25, 2006, 06:46 PM   #12
sk3pt1c
Thread Starter
macrumors 6502a
 
Join Date: Nov 2005
Location: 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??
__________________
Vi Veri Veniversum Vivus Vici
Macbook Pro 15" Retina
sk3pt1c is offline   0 Reply With Quote
Old Jan 26, 2006, 04:49 AM   #13
lexfuzo
macrumors 6502
 
Join Date: Mar 2005
Location: The heart of Europe
Quote:
Originally Posted by sk3pt1c
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.
__________________
Proud owner of an iBook 12/1.33
Soon upgrading to a MacBook Con
lexfuzo is offline   0 Reply With Quote
Old Jan 26, 2006, 09:16 AM   #14
sk3pt1c
Thread Starter
macrumors 6502a
 
Join Date: Nov 2005
Location: 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?
__________________
Vi Veri Veniversum Vivus Vici
Macbook Pro 15" Retina

Last edited by sk3pt1c; Jan 26, 2006 at 10:29 AM.
sk3pt1c is offline   0 Reply With Quote
Old Jan 26, 2006, 11:43 AM   #15
lexfuzo
macrumors 6502
 
Join Date: Mar 2005
Location: The heart of Europe
Quote:
Originally Posted by sk3pt1c
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.
__________________
Proud owner of an iBook 12/1.33
Soon upgrading to a MacBook Con
lexfuzo is offline   0 Reply With Quote
Old Jan 26, 2006, 03:12 PM   #16
sk3pt1c
Thread Starter
macrumors 6502a
 
Join Date: Nov 2005
Location: 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
__________________
Vi Veri Veniversum Vivus Vici
Macbook Pro 15" Retina
sk3pt1c is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Using OS X Server PostgreSQL database for non-Server use philbeeney Mac OS X Server, Xserve, and Networking 3 Feb 19, 2014 05:07 PM

Forum Jump

All times are GMT -5. The time now is 02:27 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC