[ADMIN] Programmatically changing passwords
Hello! I am trying to build an RPM package that will put my Postgres installation into a known (usable) state, without requiring any interaction. To this effect, I need to do the following: 1. set password for superuser 2. createuser user 3. createdb -O user dbname No problems with (3) above. But for (1) and (2), how can I set the passwords programmatically, since createuser does not let me do this (requires interactive prompt from user)? Thank you! ---(end of broadcast)--- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq
Re: [ADMIN] Programmatically changing passwords
David Leangen <[EMAIL PROTECTED]> writes: > I am trying to build an RPM package that will put my Postgres > installation into a known (usable) state, without requiring any > interaction. > To this effect, I need to do the following: > 1. set password for superuser Basically, you can't. The entire concept of RPM is built around the assumption that there is no user interaction during an RPM install or update. (Do "yum update" after not having done it for awhile ... watch several hundred package updates go by ... now imagine that each one of those felt that it could demand some input from you. Multiply by 10 if doing a system install from scratch.) The standard RPM-ization of Postgres does not actually have any superuser password set at all: you pretty much have to be root to get into the database the first time. Considering you also have to be root to install the package or start the service, I don't see any fundamental problem with that. regards, tom lane ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly
Re: [ADMIN] Programmatically changing passwords
David Leangen wrote: Hello! I am trying to build an RPM package that will put my Postgres installation into a known (usable) state, without requiring any interaction. To this effect, I need to do the following: 1. set password for superuser 2. createuser user 3. createdb -O user dbname No problems with (3) above. But for (1) and (2), how can I set the passwords programmatically, since createuser does not let me do this (requires interactive prompt from user)? ALTER USER foo with encrypted password 'bar'; CREATE USER foo; CREATE DATABASE bar owner foo; Thank you! ---(end of broadcast)--- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq -- === The PostgreSQL Company: Command Prompt, Inc. === Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240 Providing the most comprehensive PostgreSQL solutions since 1997 http://www.commandprompt.com/ ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster
Re: [ADMIN] Programmatically changing passwords
Thank you. Reply below. On Aug 10, 2006, at 13:54, Tom Lane wrote: David Leangen <[EMAIL PROTECTED]> writes: I am trying to build an RPM package that will put my Postgres installation into a known (usable) state, without requiring any interaction. To this effect, I need to do the following: 1. set password for superuser Basically, you can't. The entire concept of RPM is built around the assumption that there is no user interaction during an RPM install or update. Yes, that is my point. After having installed the standard postgresql package, I would then install my custom-postgres-config package. In this package, I tinker with the default configuration so I can put postgres into a known state programmatically, without any user interaction. The problem is that createuser doesn't allow for this: it prompts the user for a password, which does not work in this situation, as you pointed out. ---(end of broadcast)--- TIP 6: explain analyze is your friend
Re: [ADMIN] Programmatically changing passwords
Thank you! Reply below. On Aug 10, 2006, at 13:59, Joshua D. Drake wrote: David Leangen wrote: Hello! I am trying to build an RPM package that will put my Postgres installation into a known (usable) state, without requiring any interaction. To this effect, I need to do the following: 1. set password for superuser 2. createuser user 3. createdb -O user dbname No problems with (3) above. But for (1) and (2), how can I set the passwords programmatically, since createuser does not let me do this (requires interactive prompt from user)? ALTER USER foo with encrypted password 'bar'; CREATE USER foo; CREATE DATABASE bar owner foo; That makes perfect sense, but how can I do this from the shell? Is there an easy way to wrap these so I can send them to postgres from the shell? Thank you! ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org
Re: [ADMIN] Programmatically changing passwords
David Leangen <[EMAIL PROTECTED]> writes: > Yes, that is my point. After having installed the standard postgresql > package, I would then install my custom-postgres-config package. In > this package, I tinker with the default configuration so I can put > postgres into a known state programmatically, without any user > interaction. > The problem is that createuser doesn't allow for this: it prompts the > user for a password, which does not work in this situation, as you > pointed out. I rather doubt that: the default RPM installation uses ident authentication. Which has got plenty of downsides, but unexpected password prompts is not one of them. Perhaps you are making your configuration changes in a bad order? regards, tom lane ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster
Re: [ADMIN] Programmatically changing passwords
On Thursday 10 August 2006 07:12, David Leangen wrote: | > ALTER USER foo with encrypted password 'bar'; | > CREATE USER foo; | > CREATE DATABASE bar owner foo; | | That makes perfect sense, but how can I do this from the shell? Is | there an easy way to wrap these so I can send them to postgres from | the shell? yes; the following should work: #!/bin/bash psql <<_EOT_ ALTER USER foo with encrypted password 'bar'; CREATE USER foo; CREATE DATABASE bar owner foo; _EOT_ Ciao, Thomas -- Thomas Pundt <[EMAIL PROTECTED]> http://rp-online.de/ ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings
Re: [ADMIN] Programmatically changing passwords
Awesome, thank you! That is exactly what I needed. Didn't know it was that simple... duh! On Aug 10, 2006, at 14:36, Thomas Pundt wrote: On Thursday 10 August 2006 07:12, David Leangen wrote: | > ALTER USER foo with encrypted password 'bar'; | > CREATE USER foo; | > CREATE DATABASE bar owner foo; | | That makes perfect sense, but how can I do this from the shell? Is | there an easy way to wrap these so I can send them to postgres from | the shell? yes; the following should work: #!/bin/bash psql <<_EOT_ ALTER USER foo with encrypted password 'bar'; CREATE USER foo; CREATE DATABASE bar owner foo; _EOT_ Ciao, Thomas -- Thomas Pundt <[EMAIL PROTECTED]> http://rp-online.de/ ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings ---(end of broadcast)--- TIP 6: explain analyze is your friend