postgreSQL help

Discussion in 'Mac Programming' started by sk3pt1c, Jan 25, 2006.

  1. macrumors 6502a

    sk3pt1c

    Joined:
    Nov 29, 2005
    Location:
    a simulacrum
    #1
    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?
     
  2. macrumors 6502

    Joined:
    Mar 15, 2005
    Location:
    The heart of Europe
    #2
    Is the server running?
    Did you reboot the computer and not start the postmaster?
     
  3. macrumors 6502

    Joined:
    Apr 16, 2003
    Location:
    Boston, MA
    #3
    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?
     
  4. macrumors G4

    Joined:
    Jan 5, 2006
    Location:
    Redondo Beach, California
    #4
    How is the server being started?

    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.
     
  5. macrumors newbie

    Wince99

    Joined:
    Oct 31, 2005
    Location:
    Montreal
    #5
    try this link, it explains how to do it :

    http://developer.apple.com/internet/opensource/postgres.html
     
  6. macrumors 6502

    Joined:
    Mar 15, 2005
    Location:
    The heart of Europe
    #6
    No, psql assumes local connection (UNIX socket type) if no argument is given.
     
  7. thread starter macrumors 6502a

    sk3pt1c

    Joined:
    Nov 29, 2005
    Location:
    a simulacrum
    #7
    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?
     
  8. macrumors G4

    Joined:
    Jan 5, 2006
    Location:
    Redondo Beach, California
    #8
    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?


     
  9. macrumors 6502

    Joined:
    Apr 16, 2003
    Location:
    Boston, MA
    #9
    Good to know, in case I ever run into that, but I think I'll stick with mysql for my databases.
     
  10. thread starter macrumors 6502a

    sk3pt1c

    Joined:
    Nov 29, 2005
    Location:
    a simulacrum
    #10
    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...
     
  11. Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #11
    It sounds to me as if you haven't installed the engine to be automatically started with the system.
     
  12. thread starter macrumors 6502a

    sk3pt1c

    Joined:
    Nov 29, 2005
    Location:
    a simulacrum
    #12
    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??
     
  13. macrumors 6502

    Joined:
    Mar 15, 2005
    Location:
    The heart of Europe
    #13
    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.
     
  14. thread starter macrumors 6502a

    sk3pt1c

    Joined:
    Nov 29, 2005
    Location:
    a simulacrum
    #14
    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?
     
  15. macrumors 6502

    Joined:
    Mar 15, 2005
    Location:
    The heart of Europe
    #15
    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.
     
  16. thread starter macrumors 6502a

    sk3pt1c

    Joined:
    Nov 29, 2005
    Location:
    a simulacrum
    #16
    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
     

Share This Page