From: | Julien Rouhaud <rjuju123(at)gmail(dot)com> |
---|---|
To: | Alan Lin <alin(at)codecademy(dot)com> |
Cc: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: dropdb utility command prompts for password despite valid .pgpass file in home directory |
Date: | 2022-06-24 08:40:26 |
Message-ID: | 20220624084026.n7p4zsio3t2ox5mg@jrouhaud |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Hi,
On Thu, Jun 23, 2022 at 03:21:52PM -0400, Alan Lin wrote:
> Problem:
>
> I'm trying to use the dropdb utility command in non-interactive mode to
> drop an existing database (with active connections) in a test environment,
> but it keeps prompting me for the password.
>
> Here's what I'm running with `.pgpass` with valid permissions (0600) and
> location (users home directory, though I've also explicitly set the path
> using PGPASSFILE envvar). This pass file was validated to work with other
> utility commands like pg_dump.
>
> Note: "myserverhost" is not a real host - I've just redacted our actual
> hostname for this bug report.
>
> Command:
>
> ```
> dropdb --host <myserverhost.amazonaws.com> -w <mydbname>
> ```
>
> Response:
>
> ```
> dropdb: error: could not connect to database template1: connection to
> server at "<myserverhost.amazonaws.com>" (<redacted IP>), port 5432 failed:
> fe_sendauth: no password supplied
> ```
>
> Note the `template1` error despite me passing the correct database name.
This is not a bug. As mentioned in the documentation for the
maintenance-db option
(https://www.postgresql.org/docs/current/app-dropdb.html)
> --maintenance-db=dbname
> Specifies the name of the database to connect to in order to drop the target
> database. If not specified, the postgres database will be used; if that does
> not exist (or is the database being dropped), template1 will be used. This
> can be a connection string. If so, connection string parameters will override
> any conflicting command line options.
You should either specify a maintenance-db option for which there is a valid
match in your .pgass file, or adapt your .pgpass file to match the default
maintenance databases.
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2022-06-24 11:11:23 | Re: BUG #17522: While using --with-ssl=openssl and PG_TEST_EXTRA='ssl' options, SSL test fails on OpenBSD 7.1 |
Previous Message | Andrey Lepikhov | 2022-06-24 07:21:45 | Re: Errors on CREATE TABLE IF NOT EXISTS |