Обсуждение: Can't connect to socket in Debian distribution

Поиск
Список
Период
Сортировка

Can't connect to socket in Debian distribution

От
"KEVIN ZEMBOWER"
Дата:
I'm trying to set up my first postgreSQL system using the Debian distribution. I'm using the currently stable (woody)
version,and have these packages installed: 
www2:/etc/postgresql# dpkg -l |grep -i postgresql
ii  libpgsql2      7.2.1-2woody2  Shared library libpq.so.2 for PostgreSQL
ii  postgresql     7.2.1-2woody2  Object-relational SQL database, descended fr
ii  postgresql-cli 7.2.1-2woody2  Front-end programs for PostgreSQL

When I try to run psql as root, I get this error:
www2:/etc/postgresql# psql -p mnogosearch mnogosearch
psql: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.0"?

When I list /var/run/postgresql, sure enough, there's no .s.PGSQL.0:
www2:/etc/postgresql# ls -la /var/run/postgresql/
total 12
drwxr-xr-x    2 postgres postgres     4096 Nov 13 15:56 .
drwxr-xr-x    8 root     root         4096 Nov 27 06:26 ..
srwxrwxrwx    1 postgres postgres        0 Nov 13 15:56 .s.PGSQL.5432
-rw-------    1 postgres postgres       29 Nov 13 15:56 .s.PGSQL.5432.lock

Yet, if I change to the mnogosearch user, I seem to have no problems:
www2:/etc/postgresql# su mnogosearch
www2:/etc/postgresql$ psql mnogosearch
Welcome to psql, the PostgreSQL interactive terminal.
[snip]
mnogosearch=> \d
          List of relations
    Name     |   Type   |    Owner
-------------+----------+-------------
 dict        | table    | mnogosearch
[snip]
 stopword    | table    | mnogosearch
 url         | table    | mnogosearch
(18 rows)

mnogosearch=>

I would like some advice on how to fix this problem. I'd like to stay as close as possible to the Debian system. Is
thissomething I can fix in a configuration file or on the command line of the startup of postmaster or psql? 

Thanks for your advice.

-Kevin Zembower

-----
E. Kevin Zembower
Unix Administrator
Johns Hopkins University/Center for Communications Programs
111 Market Place, Suite 310
Baltimore, MD  21202
410-659-6139


Re: Can't connect to socket in Debian distribution

От
Tom Lane
Дата:
"KEVIN ZEMBOWER" <KZEMBOWER@jhuccp.org> writes:
> When I try to run psql as root, I get this error:
> www2:/etc/postgresql# psql -p mnogosearch mnogosearch
> psql: could not connect to server: No such file or directory
>         Is the server running locally and accepting
>         connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.0"?

"-p" is probably not what you want here.  It looks like the code is
failing to notice that the argument of -p doesn't look like an integer...

            regards, tom lane

Re: Can't connect to socket in Debian distribution

От
"KEVIN ZEMBOWER"
Дата:
Thank you, Tom, for your suggestions. I think it moved me in the right direction, but I'm still not there yet.

You are right about the '-p' option. It gets so confusing to me switching back and forth from MySQL to PostgreSQL. In
MySQL,'-p' is how you prompt for the password. In PostgreSQL, it's '-W'. However, now, running as root, I just get: 
www2:/home/kevinz# psql -W mnogosearch mnogosearch
Password:
psql: FATAL 1:  IDENT authentication failed for user "mnogosearch"

www2:/home/kevinz# psql -W -U mnogosearch mnogosearch
Password:
psql: FATAL 1:  IDENT authentication failed for user "mnogosearch"

Just before I tried this, I used the ALTER USER command to set the password for mnogosearch to something I was sure of,
soI'm pretty confident in that. 

When I 'su mnogosearch' I can then 'psql mnogosearch' , never get asked for a password, and get into psql immediately
andwithout a problem. 

One thing I don't understand is the difference between:
psql -W <dbname> <username>
and:
psql -W -U <username> <dbname>
My reference book leads me to believe that there's no difference. Is there?

Thanks, again, Tom.

-Kevin

>>> Tom Lane <tgl@sss.pgh.pa.us> 11/27/02 01:52PM >>>
"KEVIN ZEMBOWER" <KZEMBOWER@jhuccp.org> writes:
> When I try to run psql as root, I get this error:
> www2:/etc/postgresql# psql -p mnogosearch mnogosearch
> psql: could not connect to server: No such file or directory
>         Is the server running locally and accepting
>         connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.0"?

"-p" is probably not what you want here.  It looks like the code is
failing to notice that the argument of -p doesn't look like an integer...

            regards, tom lane


Re: Can't connect to socket in Debian distribution

От
Tom Lane
Дата:
"KEVIN ZEMBOWER" <KZEMBOWER@jhuccp.org> writes:
> www2:/home/kevinz# psql -W mnogosearch mnogosearch
> Password:
> psql: FATAL 1:  IDENT authentication failed for user "mnogosearch"
                  ^^^^^^^^^^^^^^^^^^^^

> When I 'su mnogosearch' I can then 'psql mnogosearch' , never get asked for a password, and get into psql immediately
andwithout a problem. 

Indeed, because you haven't got it configured to use password
authentication: you have it configured to use IDENT, which looks at the
Unix userid you are running as.  That has to match the Postgres userid
you are trying to connect as.

> One thing I don't understand is the difference between:
> psql -W <dbname> <username>
> and:
> psql -W -U <username> <dbname>
> My reference book leads me to believe that there's no difference. Is there?

AFAICS there should be no difference ... just a matter of taste.

            regards, tom lane

Re: Can't connect to socket in Debian distribution

От
"KEVIN ZEMBOWER"
Дата:
Thank you so much, Tom. In the confusion of trying to solve this problem, I had changed this line:
local        all                                           ident sameuser
to this:
local        all                                           md5
but, when it didn't work, I changed it back, then forgot about it. Just now, as you suggested, when I changed it back
tomd5 from ident, it worked fine. 

Thank you again for your help. Happy Thanksgiving.

-Kevin

>>> Tom Lane <tgl@sss.pgh.pa.us> 11/27/02 03:30PM >>>
"KEVIN ZEMBOWER" <KZEMBOWER@jhuccp.org> writes:
> www2:/home/kevinz# psql -W mnogosearch mnogosearch
> Password:
> psql: FATAL 1:  IDENT authentication failed for user "mnogosearch"
                  ^^^^^^^^^^^^^^^^^^^^

> When I 'su mnogosearch' I can then 'psql mnogosearch' , never get asked for a password, and get into psql immediately
andwithout a problem. 

Indeed, because you haven't got it configured to use password
authentication: you have it configured to use IDENT, which looks at the
Unix userid you are running as.  That has to match the Postgres userid
you are trying to connect as.

> One thing I don't understand is the difference between:
> psql -W <dbname> <username>
> and:
> psql -W -U <username> <dbname>
> My reference book leads me to believe that there's no difference. Is there?

AFAICS there should be no difference ... just a matter of taste.

            regards, tom lane


Re: Can't connect to socket in Debian distribution

От
Oliver Elphick
Дата:
On Wed, 2002-11-27 at 20:30, Tom Lane wrote:
> "KEVIN ZEMBOWER" <KZEMBOWER@jhuccp.org> writes:
> > www2:/home/kevinz# psql -W mnogosearch mnogosearch
> > Password:
> > psql: FATAL 1:  IDENT authentication failed for user "mnogosearch"
>                   ^^^^^^^^^^^^^^^^^^^^
>
> > When I 'su mnogosearch' I can then 'psql mnogosearch' , never get asked for a password, and get into psql
immediatelyand without a problem. 
>
> Indeed, because you haven't got it configured to use password
> authentication: you have it configured to use IDENT, which looks at the
> Unix userid you are running as.  That has to match the Postgres userid
> you are trying to connect as.

The Debian default is to use "ident sameuser" authentication.  This is
set in /etc/postgresql/pg_hba.conf.

Do you need to connect to this database as a different user?  Why not
connect to it under your own name?

    psql -d mnogosearch

If necessary the mnogosearch user may need to grant you appropriate
privileges on the tables in that database.

As with Unix logins, it seems to me to be desirable for users to connect
as themselves, so that what one does is distinguishable from what anyone
else does, should any tracing be necessary.

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight, UK                             http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "Thou, even thou, art LORD alone; thou hast made
      heaven, the heaven of heavens, with all their host,
      the earth, and all things that are therein, the seas,
      and all that is therein, and thou preservest them all;
      and the host of heaven worshippeth thee."
                                        Nehemiah 9:6

Вложения

Re: Can't connect to socket in Debian distribution

От
"KEVIN ZEMBOWER"
Дата:
This is a part of the mnogosearch system that's confusing to me. However, this is my first experience with mnogosearch
andalso with postgreSQL. I'm assuming that the Apache httpd software, which runs as "nobody:nogroup" in Debian, will
runthe mnogosearch php script to search the index and return the results. So, 'nobody:nogroup' will have to log into
themnogosearch database as dbuser 'mnogosearch.' At least, I think this is what's needed. But, I'm still working on it. 

Thanks for writing.

-Kevin

>>> Oliver Elphick <olly@lfix.co.uk> 11/27/02 04:38PM >>>
On Wed, 2002-11-27 at 20:30, Tom Lane wrote:
> "KEVIN ZEMBOWER" <KZEMBOWER@jhuccp.org> writes:
> > www2:/home/kevinz# psql -W mnogosearch mnogosearch
> > Password:
> > psql: FATAL 1:  IDENT authentication failed for user "mnogosearch"
>                   ^^^^^^^^^^^^^^^^^^^^
>
> > When I 'su mnogosearch' I can then 'psql mnogosearch' , never get asked for a password, and get into psql
immediatelyand without a problem. 
>
> Indeed, because you haven't got it configured to use password
> authentication: you have it configured to use IDENT, which looks at the
> Unix userid you are running as.  That has to match the Postgres userid
> you are trying to connect as.

The Debian default is to use "ident sameuser" authentication.  This is
set in /etc/postgresql/pg_hba.conf.

Do you need to connect to this database as a different user?  Why not
connect to it under your own name?

    psql -d mnogosearch

If necessary the mnogosearch user may need to grant you appropriate
privileges on the tables in that database.

As with Unix logins, it seems to me to be desirable for users to connect
as themselves, so that what one does is distinguishable from what anyone
else does, should any tracing be necessary.

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight, UK                             http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "Thou, even thou, art LORD alone; thou hast made
      heaven, the heaven of heavens, with all their host,
      the earth, and all things that are therein, the seas,
      and all that is therein, and thou preservest them all;
      and the host of heaven worshippeth thee."
                                        Nehemiah 9:6


Re: Can't connect to socket in Debian distribution

От
brew@theMode.com
Дата:
On Wed, 27 Nov 2002, KEVIN ZEMBOWER wrote:

> I'm assuming that the Apache httpd software, which runs as
> "nobody:nogroup" in Debian, will run the mnogosearch php script to
> search the index and return the results. So, 'nobody:nogroup' will have
> to log into the mnogosearch database as dbuser 'mnogosearch.' At least,
> I think this is what's needed. But, I'm still working on it.

It doesn't have to.... read the PostgreSQL docs about DB user names and
unix users names.  I think you can give whatever username you want at
the command line and I know I give a username at the connect line in my
php scripts.

If you haven't got the PostgreSQL docs on your Debian system get them, run
the command:

apt-get update

then

apt-get install postgresql-doc


later.....

brew