Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id B2F062E0052 for ; Wed, 20 Feb 2008 04:06:26 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 65159-02 for ; Wed, 20 Feb 2008 04:06:23 -0400 (AST) Received: from ipmail01.adl6.internode.on.net (ipmail01.adl6.internode.on.net [203.16.214.146]) by postgresql.org (Postfix) with ESMTP id 2D5772E0043 for ; Wed, 20 Feb 2008 04:06:22 -0400 (AST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ah4FAL9tu0fLevdH/2dsb2JhbAAsgS2KYYVqngs X-IronPort-AV: E=Sophos;i="4.25,380,1199626200"; d="scan'208";a="45678409" Received: from ppp247-71.static.internode.on.net (HELO DevBox.local) ([203.122.247.71]) by ipmail01.adl6.internode.on.net with ESMTP; 20 Feb 2008 18:36:19 +1030 Message-ID: <47BBDF78.7070801@Sheeky.Biz> Date: Wed, 20 Feb 2008 18:36:16 +1030 From: Shane Ambler User-Agent: Thunderbird 2.0.0.6 (Macintosh/20070728) MIME-Version: 1.0 To: Rajiv Rajaian CC: pgsql-admin@postgresql.org Subject: Re: How to create a new user with password in commandline with no prompt for password References: <238696420802192330g69e3c447jeadd1d3d31506eda@mail.gmail.com> In-Reply-To: <238696420802192330g69e3c447jeadd1d3d31506eda@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/224 X-Sequence-Number: 28298 Rajiv Rajaian wrote: > Hi all > Im using postgresql-8.0.3-1. > I need to create a new user in postgresql with password ..But it should not > prompt me to get the password ..ie only through command line I've to give > the password as input > Steps i had done are as follows > > [root@g151 ~]# su postgres -c "createuser -A -d globus" > could not change directory to "/root" > CREATE USER For adding a user in SQL with a password you can use - CREATE ROLE name WITH [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password'; Using that from the command line you can - echo "CREATE ROLE name....." | psql -U postgres to bypass the password prompt. > [root@g151 ~]# su globus -c "createdb rftDatabase" > could not change directory to "/root" > CREATE DATABASE > > > Also in /var/lib./pgsql/data/pg_hba.conf I ve added the entry as > > host rftDatabase "globus" "172.16.10.151" 255.255.255.0 md5 > > Now when i tried to login to that database I got the following error > > [root@g151 ~]# psql -U globus -d rftdatabase > psql: FATAL: Ident authentication failed for user "globus" Your pg_hba.conf line above says a password must be used. You can add a line with your no password account using trust to get past that. The other way around that is to use a .pgpass file in your local home dir. http://www.postgresql.org/docs/8.3/interactive/libpq-pgpass.html for more detail. > Also with password promt it was prompting password ..But I haven't created > the user with password > [root@g151 ~]# psql -U globus -d rftdatabase -W > Password: > > > Is it possible to create any new user in postgresql with password through > command line and with no prompt for password.??Is there any option in > Postgresql? > Also if I create a new user with su postgres -c "createuser -A -d > globus" .Will it set any default password while creating the user ?? No password is stored unless you specify it. As much as these are ways around your inconveniences, you should also consider the security implications of using them. -- Shane Ambler pgSQL (at) Sheeky (dot) Biz Get Sheeky @ http://Sheeky.Biz