pgreplay-go
pgreplay-go copied to clipboard
How to authenticate with a password?
Hi there, I'm trying to run
a logfile against an RDS server, and I can't for the life of me figure out how to authenticate with a password.
At first I assumed I would be prompted:
$ ./pgreplay run --host=server.rds.amazonaws.com --database=db --user=user --errlog-input=logfile
ts=2022-01-28T16:57:01.31160049Z caller=level.go:63 event=metrics.listen address=127.0.0.1 port=9445
ts=2022-01-28T16:57:01.584684653Z caller=level.go:63 event=postgres.error error="FATAL: password authentication failed for user \"user\" (SQLSTATE 28P01)"
Double checked --help
, saw no password
or similar switch but tried a few anyway:
$ ./pgreplay run --host=server.rds.amazonaws.com --database=db --user=user --password=password --errlog-input=logfile
pgreplay: error: unknown long flag '--password', try --help
$ ./pgreplay run --host=server.rds.amazonaws.com --database=db --user=user --pwd=password --errlog-input=logfile
pgreplay: error: unknown long flag '--pwd', try --help
Thought maybe a full connection string might be accepted:
$ ./pgreplay run --host='postgresql://user:[email protected]/db' --errlog-input=logfile
ts=2022-01-28T16:59:23.090820874Z caller=level.go:63 event=postgres.error error="dial tcp: address postgresql://user:[email protected]/db:5432: too many colons in address"
Found an old issue here that seemed to reference integration_test.go and thought to try PGPASSWORD
$ export PGPASSWORD=password
$ echo $PGPASSWORD
password
$ ./pgreplay run --host=server.rds.amazonaws.com --database=db --user=user --errlog-input=logfile
ts=2022-01-28T16:57:01.31160049Z caller=level.go:63 event=metrics.listen address=127.0.0.1 port=9445
ts=2022-01-28T16:57:01.584684653Z caller=level.go:63 event=postgres.error error="FATAL: password authentication failed for user \"user\" (SQLSTATE 28P01)"
I'm certain the credentials I'm using are correct for this sever and database -- the connection string works in my app, and the host, user and password combination works in Datagrip, and psql connects just fine with psql --host='server.rds.amazonaws.com' --dbname='db' --username='user'
so the environment variable seems to be property set.
I poked at the source a little bit but I don't grok enough Go to figure out where the pgreplay command might be looking to get a password. So, help?
EDIT:
I had a look at https://github.com/jackc/pgx and it looks as though a URL should be supported but it clearly isn't. Also tried a postgres:
scheme instead of postgresql:
and that also doesn't work.
I got this working by adding a password here and passing it in here. The rest of the documentation is lacking though so I didn't get much further.
@lamontadams This is certainly odd, I would expect what you're trying to do to work OK. The only other option that I can suggest would be to set up a .pgpass
file and ensure that $PGPASSFILE
points to it. pgx
should respect this.
FWIW when running this within our infrastructure we've used totally isolated test environments, and therefore been able to modify the pg_hba.conf
to trust
all incoming connections, hence not spotting this issue.
#19 closes this