pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: bwnabble <bwiese@cotse.com>
To: pgsql-admin@postgresql.org
Subject: after initdb - Re: How to CREATEDB in commandline with no prompt for password
Date: Mon, 3 Mar 2008 16:50:58 -0800 (PST)
Message-ID: <15817886.post@talk.nabble.com> (raw)
In-Reply-To: <238696420802200311y40a93a38jbd601e280d2fb860@mail.gmail.com>
References: <238696420802192330g69e3c447jeadd1d3d31506eda@mail.gmail.com>
	<47BBDF78.7070801@Sheeky.Biz>
	<238696420802200115m522cfd11h2f37d87845c2d6e0@mail.gmail.com>
	<238696420802200219y7bfd4269u498dd1fe0b80c2cc@mail.gmail.com>
	<238696420802200311y40a93a38jbd601e280d2fb860@mail.gmail.com>




Rajiv Rajaian-2 wrote:
> 
> [root@g151 ~]# su postgres -c "createdb postgres"
> could not change directory to "/root"
> CREATE DATABASE
> [root@g151 ~]# echo "CREATE USER globus WITH PASSWORD 'globus' CREATEDB;"
> |
> psql -U postgres -d postgres
> psql: FATAL:  Ident authentication failed for user "postgres"
> [root@g151 ~]# su postgres -c "echo \"CREATE USER globus WITH PASSWORD
> 'globus' CREATEDB;\" | psql -U postgres -d postgres"
> could not change directory to "/root"
> CREATE USER
> [root@g151 ~]# su globus -c "createdb rftDatabase"
> could not change directory to "/root"
> CREATE DATABASE
> 

Rajiv,

Did you have your METHODs set to "trust" in your "pg_hba.conf" file (in the
$PGDATA directory)?

My question is, similar to yours, is there a way to:
1) run "initdb" as user "postgres" on an empty $PGDATA directory to start
from scratch
2) change the METHODs in "$PGDATA/pg_hba.conf" from "trust" -> "password"
3) start the postgresql server
4) run "createdb mydb" with no prompt for a password? (as user root or
postgres?)

I can only perform step 4 (createdb mydb) when the default METHOD is "trust"
in pg_hba.conf and I'm wondering if is any way around it?  I want to disable
"trust" for security purposes.

Must I use the METHOD "trust" first in order to create a user with
"createdb" privileges, and then change METHODs in pg_hba.conf from "trust"
to "password"?

-- 
View this message in context: http://www.nabble.com/How-to-create-a-new-user-with-password-in-commandline-with-no-prompt-for-passw...
Sent from the PostgreSQL - admin mailing list archive at Nabble.com.




view thread (3+ messages)  latest in thread

Message-ID: <15817886.post@talk.nabble.com>
Permalink:  ../15817886.post@talk.nabble.com/
Also on:    postgresql.org/message-id/15817886.post@talk.nabble.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: bwiese@cotse.com
  Subject: Re: after initdb - Re: How to CREATEDB in commandline with no prompt for password
  In-Reply-To: <15817886.post@talk.nabble.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox