Thread: postgres db deleted and recreated... "No directory, logging in with HOME=/" error...

hi all,

thanks for the good information and advise.  i've
learned something from everyone's replies.  i have
open office open and i'm keeping good notes.

i'm now reading up on how to create a role for my os
user so that the os user can have full privileges on
the db.

i think this won't be a problem.

so why am i posting, you ask?  great question.  ;-)

well, i dropped the "postgres" db in order to create a
"rails" db.  i tried to do some stuff and i kept
getting the error that postgres didn't exist.  then i
remembered that was likely because it was the default
db required to work with other dbs.

ooops!

i had created a postgres db earlier, so i thought
deleting postgres would only impact what i had
previously created (i think postgres already existed
in the distro, now that i look back).

anyway, i recreated postgres, but when i "su -
postgres"... i get the following error:

No directory, logging in with HOME=/

i think i must've deleted a directory when i deleted
postgres and it wasn't recreated when i recreated
postgres.

what can i do, if anything, to get back on track after
delting and recreating the postgres db?  i'm running
simply mepis, which is based on debian.

as always, tia...

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Re: postgres db deleted and recreated... "No directory,

From
John Purser
Date:
On Sat, 6 May 2006 10:11:55 -0700 (PDT)
<operationsengineer1@yahoo.com> wrote:

> well, i dropped the "postgres" db in order to create a
> "rails" db.  i tried to do some stuff and i kept
> getting the error that postgres didn't exist.  then i
> remembered that was likely because it was the default
> db required to work with other dbs.
>
> ooops!
>
> i had created a postgres db earlier, so i thought
> deleting postgres would only impact what i had
> previously created (i think postgres already existed
> in the distro, now that i look back).
>
> anyway, i recreated postgres, but when i "su -
> postgres"... i get the following error:
>
> No directory, logging in with HOME=/
>
> i think i must've deleted a directory when i deleted
> postgres and it wasn't recreated when i recreated
> postgres.
>
> what can i do, if anything, to get back on track after
> delting and recreating the postgres db?  i'm running
> simply mepis, which is based on debian.
>
> as always, tia...
> ---------------------------(end of
> broadcast)--------------------------- TIP 5: don't forget to increase
> your free space map settings

I think you're getting an error from linux (assuming you're on linux)
not postgres.  When you su - postrgres it tries to sign you in as user
postgres and if this is an installation from a distro package there
probably isn't a directory call /home/postgres.  So linux is logging
you in with / as your "home" directory.

Remember that postgres and linux accounts are seperate.  You can long
in as "joe" to linux and then log into postgres in postgreSQL with the
command:
psql -U postgres

If you REALLY need to su to postgres then you might want to create
a /home/postgres directory:
mkdir -p /home/postgres      #as root
chown postgres:postgres     /home/postgres   #as root
Then look at your password file to make sure postgres is set up as a
real user.  Open up a text editor as root and see if there's a line
like:
postgres:x:1001:1001:postgresql:/home/postgres:/bin/bash
This tells Linux that there is a user named postgres, who's password is
held in the shadow password file, his user ID is 1001, his group ID is
1001 and his HOME DIRECTORY is /home/postgres and he uses the bash
shell.

But again, you DON'T need to be logged in as postgres ON LINUX to
access the postgres database ON POSTGRESQL.

Hope this gets you off on the right foot.

John Purser


--
Q:    How many journalists does it take to screw in a light bulb?
A:    Three.  One to report it as an inspired government program to
bring light to the people, one to report it as a diabolical government
plot to deprive the poor of darkness, and one to win a Pulitzer prize
for reporting that Electric Company hired a light bulb-assassin to break
    the bulb in the first place.

> On Sat, 6 May 2006 10:11:55 -0700 (PDT)
> <operationsengineer1@yahoo.com> wrote:
>
> > well, i dropped the "postgres" db in order to
> create a
> > "rails" db.  i tried to do some stuff and i kept
> > getting the error that postgres didn't exist.
> then i
> > remembered that was likely because it was the
> default
> > db required to work with other dbs.
> >
> > ooops!
> >
> > i had created a postgres db earlier, so i thought
> > deleting postgres would only impact what i had
> > previously created (i think postgres already
> existed
> > in the distro, now that i look back).
> >
> > anyway, i recreated postgres, but when i "su -
> > postgres"... i get the following error:
> >
> > No directory, logging in with HOME=/
> >
> > i think i must've deleted a directory when i
> deleted
> > postgres and it wasn't recreated when i recreated
> > postgres.
> >
> > what can i do, if anything, to get back on track
> after
> > delting and recreating the postgres db?  i'm
> running
> > simply mepis, which is based on debian.
> >
> > as always, tia...
> > ---------------------------(end of
> > broadcast)--------------------------- TIP 5: don't
> forget to increase
> > your free space map settings
>
> I think you're getting an error from linux (assuming
> you're on linux)
> not postgres.  When you su - postrgres it tries to
> sign you in as user
> postgres and if this is an installation from a
> distro package there
> probably isn't a directory call /home/postgres.  So
> linux is logging
> you in with / as your "home" directory.
>
> Remember that postgres and linux accounts are
> seperate.  You can long
> in as "joe" to linux and then log into postgres in
> postgreSQL with the
> command:
> psql -U postgres
>
> If you REALLY need to su to postgres then you might
> want to create
> a /home/postgres directory:
> mkdir -p /home/postgres      #as root
> chown postgres:postgres     /home/postgres   #as root
> Then look at your password file to make sure
> postgres is set up as a
> real user.  Open up a text editor as root and see if
> there's a line
> like:
>
postgres:x:1001:1001:postgresql:/home/postgres:/bin/bash
> This tells Linux that there is a user named
> postgres, who's password is
> held in the shadow password file, his user ID is
> 1001, his group ID is
> 1001 and his HOME DIRECTORY is /home/postgres and he
> uses the bash
> shell.
>
> But again, you DON'T need to be logged in as
> postgres ON LINUX to
> access the postgres database ON POSTGRESQL.
>
> Hope this gets you off on the right foot.
>
> John Purser

yes, this helped a lot.  however, i'm getting an error
message...

user@7[/]$ psql -U postgres
psql: FATAL:  Ident authentication failed for user
"postgres"
user@7[/]$ su root
Password:
root@7[/]# psql -U postgres
psql: FATAL:  Ident authentication failed for user
"postgres"

postgres exists, as shown by the following:

postgres@7[/]$ psql
Welcome to psql 8.1.3, the PostgreSQL interactive
terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

postgres=# \du
                               List of roles
 Role name | Superuser | Create role | Create DB |
Connections | Member of
-----------+-----------+-------------+-----------+-------------+-----------
 postgres  | yes       | yes         | yes       | no
limit    |
(1 row)

postgres=#

where to go from here?

tia...

ps - i'm getting close, i can smell it!  thanks for
being patient.



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Re: postgres db deleted and recreated... "No directory,

From
Devrim GUNDUZ
Date:
Hi,

On Sat, 2006-05-06 at 12:26 -0700, operationsengineer1@yahoo.com wrote:
> user@7[/]$ su root
> Password:
> root@7[/]# psql -U postgres
> psql: FATAL:  Ident authentication failed for user
> "postgres"

Run su - postgres and then psql for ident auth.

See

http://www.postgresql.org/docs/8.1/static/client-authentication.html

about client authentication details.

Regards,
--
The PostgreSQL Company - Command Prompt, Inc. 1.503.667.4564
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
Managed Services, Shared and Dedicated Hosting
Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/



On Sat, May 06, 2006 at 12:26:14PM -0700, operationsengineer1@yahoo.com wrote:
> > On Sat, 6 May 2006 10:11:55 -0700 (PDT)
> > <operationsengineer1@yahoo.com> wrote:
> >
> > > well, i dropped the "postgres" db in order to
> > create a
> > > "rails" db.  i tried to do some stuff and i kept
> > > getting the error that postgres didn't exist.
> > then i
> > > remembered that was likely because it was the
> > default
> > > db required to work with other dbs.
> > >
> > > ooops!

> > > anyway, i recreated postgres, but when i "su -
> > > postgres"... i get the following error:
> > >
> > > No directory, logging in with HOME=/
> > >
> > > i think i must've deleted a directory when i
> > deleted
> > > postgres and it wasn't recreated when i recreated
> > > postgres.

FWIW, here's the postgres entry in my /etc/passwd file

postgres:x:31:32:postgres:/var/lib/postgres:/bin/sh

The user ID of 31 indicates that he's entered as a system user.
His home directory is /var/lib/postgres
His login shell is sh, but that probably isn't important.

Umm.. did you delete the _Linux user_ postgres or just the postgres
database?

> yes, this helped a lot.  however, i'm getting an error
> message...
>
> user@7[/]$ psql -U postgres
> psql: FATAL:  Ident authentication failed for user
> "postgres"
> user@7[/]$ su root
> Password:
> root@7[/]# psql -U postgres
> psql: FATAL:  Ident authentication failed for user
> "postgres"

This is because you're using ident authentication for user postgres.  I
don't think you can use this option with ident authentication, because
ident authentication checks to see if you're who you say you are, and as
above, it doesn't see you as being postgres, but as root.  As I noted in
my previous reply, my postgres user authenticates (locally) by this
method.  You will have to su to root and then su to postgres, or
directly with a command like

su -c 'su postgres'

Then, when you're done acting as postgres, you can type exit at the
command prompt and revert straight back to the user you were.

Alternatively, if all you want to do is execute one command as postgres,
you can do as I suggested in my other post.

> where to go from here?
>
> tia...
>
> ps - i'm getting close, i can smell it!  thanks for
> being patient.

Sure, it just takes some getting used to.

> Hi,
>
> On Sat, 2006-05-06 at 12:26 -0700,
> operationsengineer1@yahoo.com wrote:
> > user@7[/]$ su root
> > Password:
> > root@7[/]# psql -U postgres
> > psql: FATAL:  Ident authentication failed for user
> > "postgres"
>
> Run su - postgres and then psql for ident auth.
>
> See
>
>
http://www.postgresql.org/docs/8.1/static/client-authentication.html
>
> about client authentication details.
>
> Regards,

thaks for the tips.  i added

local   all         all           trust

to pg_hba.conf and so far so good.  obviously, i have
a little more to learn about this topic.  the manual
is great and all, but i find them dry.  i *really* get
along better with tutorials that have lots of specific
examples.  does anyone know of a good tutorial that
covers this topic?

also, be sure to us pg_ctl to reload when you change
pg_hba.conf or the changes to it don't take effect.

the statement required to reload:

usr/lib/postgresql/8.1/bin/pg_ctl reload -D
/var/lib/postgresql/8.1/main

is a bit excessive.  i seem to recall (from my cygwin
days ;-) there is a file where i can include this path
so i don't have to type it out each time.  can anyone
give any hints to make this easier?

tia...

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Re: postgres db deleted and recreated... "No directory,

From
"Andrej Ricnik-Bay"
Date:
On 5/7/06, operationsengineer1@yahoo.com
> the statement required to reload:
>
> usr/lib/postgresql/8.1/bin/pg_ctl reload -D
> /var/lib/postgresql/8.1/main

Many individuals (distro maintainers) will have an init-script
that takes parameters ...
In slack (on my machines) it'll be
/etc/rc.d/rc.postgres (start|stop|reload)

In debian based systems
/etc/init.d/postgresql
(sometimes with postgresql-<version-mumble>)


Cheers,
Andrej



--
Please don't top post, and don't use HTML e-Mail :}  Make your quotes concise.

http://www.american.edu/econ/notes/htmlmail.htm

On Sat, May 06, 2006 at 16:58:47 -0500,
  David <dbree@duo-county.com> wrote:
>
> This is because you're using ident authentication for user postgres.  I
> don't think you can use this option with ident authentication, because
> ident authentication checks to see if you're who you say you are, and as
> above, it doesn't see you as being postgres, but as root.  As I noted in
> my previous reply, my postgres user authenticates (locally) by this
> method.  You will have to su to root and then su to postgres, or
> directly with a command like

You can use -U with ident authentication. You need to set up custom maps
to make it useful. I normally do things that way.