Re: [GENERAL] createuser: How to specify a database to connect to

Поиск
Список
Период
Сортировка
От Schmid Andreas
Тема Re: [GENERAL] createuser: How to specify a database to connect to
Дата
Msg-id b56c202c35d74455a8785b354cbb156f@bd.so.ch
обсуждение исходный текст
Ответ на Re: [GENERAL] createuser: How to specify a database to connect to  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-general
> -----Ursprüngliche Nachricht-----
> Von: Adrian Klaver [mailto:adrian.klaver@aklaver.com]
> Gesendet: Montag, 13. März 2017 17:28
> An: Tom Lane
> Cc: Schmid Andreas; 'pgsql-general@postgresql.org'
> Betreff: Re: [GENERAL] createuser: How to specify a database to connect to
>
> On 03/13/2017 09:19 AM, Tom Lane wrote:
> > Adrian Klaver <adrian.klaver@aklaver.com> writes:
> >> On 03/13/2017 08:52 AM, Tom Lane wrote:
> >>> If by "history" you're worried about the server-side statement log, this
> >>> is merest fantasy: the createuser program is not magic, it just constructs
> >>> and sends a CREATE USER command for you.  You'd actually be more secure
> >>> using psql, where (if you're superuser) you could shut off log_statement
> >>> for your session first.
> >
> >> There is a difference though:
> >
> >> psql> CREATE USER:
> >
> >> postgres-2017-03-13 09:03:27.147 PDT-0LOG:  statement: create user
> >> dummy_user with login password '1234';
> >
> > Well, what you're supposed to do is
> >
> > postgres=# create user dummy_user;
> > postgres=# \password dummy_user
> > Enter new password:
> > Enter it again:
> > postgres=#
> >
> > which will result in sending something like
> >
> > ALTER USER dummy_user PASSWORD 'md5c5e9567bc40082671d02c654260e0e09'
> >
> > You can additionally protect that by wrapping it into one transaction
> > (if you have a setup where the momentary existence of the role without a
> > password would be problematic) and/or shutting off logging beforehand.
>
> Got it.
>
> >
> >             regards, tom lane
> >
>
>
> --
> Adrian Klaver
> adrian.klaver@aklaver.com


Got it, too.
I actually was worried about the .psql_history.
So my command for adding a new user is going to be

echo 'CREATE USER dummy_user; \password dummy_user' | psql -h my.host.name dbname myusername

(I like the one liners.)

Thanks a lot to all of you for pointing out these different solutions. Great to know that even if we apparently
configuredit in an unreasonable way, PostgreSQL still allows me to achieve what I want... 

Best wishes,
Andreas



В списке pgsql-general по дате отправления:

Предыдущее
От: Rakesh Kumar
Дата:
Сообщение: Re: [GENERAL] PostgreSQL general discussions list - 2010 Thread:Wikipedia entry - AmigaOS port - error?
Следующее
От: Alexander Farber
Дата:
Сообщение: [GENERAL] UPDATE ... ON CONFLICT DO NOTHING