pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-admin@postgresql.org
Subject: Re: Creating role using batch file in windows
Date: Tue, 26 Oct 2010 10:50:58 +0200
Message-ID: <ia64pi$1h1$1@dough.gmane.org> (raw)
In-Reply-To: <AANLkTikoz3R5B6gWMdaBZxWL03ckXdumPmeXFKV2vqeK@mail.gmail.com>
References: <AANLkTi=xD4W4tiOSJyrvBTp6pt4RD+8jjEKeut6idhXh@mail.gmail.com>
	<ia42qk$fb7$1@dough.gmane.org>
	<AANLkTikoz3R5B6gWMdaBZxWL03ckXdumPmeXFKV2vqeK@mail.gmail.com>

Lukasz Brodziak, 26.10.2010 08:58:
>> The problem with a batch file is that you will need to provide the password
>> for the superuser in clear text - which is probably not something you will
>> want to do.
>>
>> But if that isn't a problem (and you actually know the superuser password of
>> your client) then the following might work:
>>
>> ------------- snip ---------------
>> @echo off
>> setlocal
>>
>> set PGHOST=localhost
>> set PGUSER=postgres
>> set PGPASSWORD=the_super_secret_password
>>
>> createuser role_1 1>  nul 2>&1
>> createuser role_2 1>  nul 2>&1
>> ...
>>
>> endlocal
>> ------------- snip ---------------
>>
>>
> One more question. Does the SET PGPASSWORD sets pass for the role?

No, it sets the password for the superuser (the one that is needed to run createrole)

> If not how to set the password for the role using the script provided.

I don't think this can be specified with createuser, but you could use psql to run a single statememt.

Something like:

psql -c "create role new_role  with password 'new_roles_password'"

(You might need to play around with the quoting)
The environment variables are then used to establish the connection to the correct Postgres instance.

Regards
Thomas











view thread (4+ messages)

Message-ID: <ia64pi$1h1$1@dough.gmane.org>
Permalink:  ../ia64pi$1h1$1@dough.gmane.org/
Also on:    postgresql.org/message-id/ia64pi$1h1$1@dough.gmane.org

 · 

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: spam_eater@gmx.net
  Subject: Re: Creating role using batch file in windows
  In-Reply-To: <ia64pi$1h1$1@dough.gmane.org>

* 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