Re: starting postgres/psql

Lists: pgsql-novice
From: Robert Morgan <robert_(at)ihug(dot)co(dot)nz>
To: postgres <pgsql-novice(at)postgresql(dot)org>
Subject: starting postgres/psql
Date: 2004-04-28 20:12:32
Message-ID: 1083183151.3502.11.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Back again,I still cant access the dbms I have created the user postgres
and started postgres.

[root(at)localhost bob]# su postgres
bash-2.05b$ /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l
logfile start
/usr/local/pgsql/bin/pg_ctl: line 341: logfile: Permission denied
postmaster successfully started

this brings me to the bash-2. 05b$ prompt where I tried

bash-2.05b$ psql -d template1
bash: psql: command not found
bash-2.05b$

so how do I get access?

Bob


From: Ron St-Pierre <rstpierre(at)syscor(dot)com>
To: Robert Morgan <robert_(at)ihug(dot)co(dot)nz>, pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: starting postgres/psql
Date: 2004-04-28 20:58:42
Message-ID: 40901B02.9010307@syscor.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Robert Morgan wrote:

>Back again,I still cant access the dbms I have created the user postgres
>and started postgres.
>
>[root(at)localhost bob]# su postgres
>bash-2.05b$ /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l
>logfile start
>/usr/local/pgsql/bin/pg_ctl: line 341: logfile: Permission denied
>
Okay, you installed and initdb'd the database as user postgres, right?
Then one of these should fix it:

- Make sure that user postgres 'owns' the directory and its subdirectories:
as user root:
chown -R postgres.postgres /usr/local/pgsql
(user postgres belongs to group postgres in this example)

- Make sure that /bin is in postgres' path (in .bash_profile)

export PATH=$PATH:/usr/local/java/bin:/usr/local/ant/bin:/usr/local/pgsql/bin
^ ^ ^ ^

(you may want/need/disregard the java and ant)

Then su to user postgres:
su - postgres
and your psql -d template1 should work

Ron


From: Andrew Kelly <akelly(at)transparency(dot)org>
To: postgres <pgsql-novice(at)postgresql(dot)org>
Subject: Re: starting postgres/psql
Date: 2004-04-29 07:02:52
Message-ID: 1083222169.4133.52.camel@hermes.at.home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Hi Bob,

On Wed, 2004-04-28 at 22:12, Robert Morgan wrote:
> Back again,I still cant access the dbms I have created the user postgres
> and started postgres.
>
> [root(at)localhost bob]# su postgres

Be careful with your execution of su, Bob.
The command you want is 'su - postgres' and not just 'su postgres'.
The way you've done it (here and in subsequent posts) does in fact make
you the postgres user, but without the '-' you do not get the
environment of the postgres user. man su will help.

> bash-2.05b$ /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l
> logfile start
> /usr/local/pgsql/bin/pg_ctl: line 341: logfile: Permission denied
> postmaster successfully started

That command is correct syntactically, but I'm not sure you're
understanding what's going on when you issue it.
First of all, the absolute path to the executable is necessary because
you didn't use the '-' when you su'd to postgres, so
/usr/local/pgsql/bin is not be in your PATH. Had you done 'su -
postgres' you could simply have done pg_ctl -D /usr/local/pgsql/data
(or ./pg_ctl if you are already in the /usr/local/pgsql/bin dir.)

pg_ctl is a utility for starting, stopping, or restarting postmaster(1),
the PostgreSQL back-end server, or displaying the status of a running
postmaster.

[That's the first line in the pg_ctl man page, by the way.]

The 'start' at the end of your command string is what you are telling
pg_ctl you want it to do, and '-D /usr/local/pgsql/data' is what it is
that you want pg_ctl to start.
And it all worked as you see: "postmaster successfully started".

But you've also told pg_ctl with the '-l' switch that the postmaster
process should log to a file and you've told it the file should be
called logfile.

You've said as user postmaster "create a file called 'logfile' in this
directory and write to it". Clearly the postgres user does not have
permission to write to the directory from which you issued your start
command. (And for the sake of clarity, you might want to name your log
file something other than logfile.

> this brings me to the bash-2. 05b$ prompt where I tried
>
> bash-2.05b$ psql -d template1
> bash: psql: command not found
> bash-2.05b$

No, of course it wouldn't be. The command psql is in
/usr/local/pgsql/bin which is in the PATH of user postgres, but *not* in
the PATH of the user root. You as user root said 'su postgres' which
means "I wish to become postres, but I want to keep my own environment".
Had you instead done 'su - postgres' the command above would have
succeeded for you.
>
> so how do I get access?
>
An honest answer? Read the man pages for 'su' and 'bash', and then for
'postmaster', 'posgres' and 'pg_ctl'.
The problems you're having here (and in subsequent posts) are, well,
trivial. I don't mean that to be insulting. I mean that in the true
sense of the word. You're getting caught on little things like
permissions issues and the correct execution of basic shell commands,
all of which could be cleared up with 10 minutes of man page reading.

I might be misremembering here and forgive me if I am, but something I
read in one of your other posts shows that you are also unfamiliar with
what mysql is, so I'm rather curious about something. What is it you
intend or hope to do with postgres once you've got a functioning
deployment in place? You seem somewhat unsure in a shell; are you
familiar with SQL?

Andy