after initdb - Re: How to CREATEDB in commandline with no prompt for password

From: bwnabble <bwiese(at)cotse(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: after initdb - Re: How to CREATEDB in commandline with no prompt for password
Date: 2008-03-04 02:28:05
Message-ID: 15818939.post@talk.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-es-ayuda

Rajiv Rajaian-2 wrote:
>
> [root(at)g151 ~]# su postgres -c "createdb postgres"
> could not change directory to "/root"
> CREATE DATABASE
> [root(at)g151 ~]# echo "CREATE USER globus WITH PASSWORD 'globus' CREATEDB;"
> |
> psql -U postgres -d postgres
> psql: FATAL: Ident authentication failed for user "postgres"
> [root(at)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(at)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-password-tp15583904p15818939.html
Sent from the PostgreSQL - admin mailing list archive at Nabble.com.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message chris.jurado 2008-03-04 04:41:57 Replacing the corrupt "global" folder with older one
Previous Message bwnabble 2008-03-04 00:50:58 after initdb - Re: How to CREATEDB in commandline with no prompt for password

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Santiago Zarate 2008-03-04 02:37:22 Re: Dudas Sobre Postgresql en OLAP
Previous Message Santiago Zarate 2008-03-04 02:20:42 Re: Postgresql 8.4 caracteristicas