[Babase] connecting to psql

Hunter Matthews babase@www.eco.princeton.edu
Thu, 06 Oct 2005 11:21:08 -0400


On Wed, 2005-10-05 at 14:43, Leah Gerber wrote:

> 
> psql: could not connect to server: Permission denied
>         Is the server running locally and accepting
>         connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
> 
> I am wondering which directory I should be in to try this? I am not 
> sure where the actual database is located on papio and if it matters 
> where I am when I try psql?

[Not sure if these questions were answered earlier, will answer them
now:]

1. psql (like most but not quite all unix programs) doesn't care where
you are when you run it.

2. The database on papio isn't a file on disk (yes yes, its stored on
the disk SOMEWHERE, but theoretically only weirdos like me or Karl
really care where) its a "service" that runs using the network.

You tell psql where on the network with either the PGHOST environment
variable, or by using the "-h" flag when you run psql. Like this:
psql -h localhost babase_test

3. The error you got above exposes a tiny lie of mine - there _is_ a
file (sort of) that will let you into the babase database(s), but I
reserve that file for the backup system and other admin tasks that I or
karl do, and everyone else has to use a password and a network name to
get in.

The bottom line is to set your PGHOST or to use the -h flag.

4. psql [options/flags/whatnot] name_of_database

the really useful flags (there are a ton of them) are 
-h hostname      -- specify which host to connect to
-U username      -- if for some reason Karl ever tells you to use a 
                    different database username

Maybe that was too much explanation, sorry. 
Are there any other questions like these? they were all good ones.
-- 
Hunter Matthews                          Unix / Network Administrator
Office: BioScience 145/244               Duke Univ. Biology Department
Key: F0F88438 / FFB5 34C0 B350 99A4 BB02  9779 A5DB 8B09 F0F8 8438
Never take candy from strangers. Especially on the internet.