Search code examples
postgresqllibpqchange-data-capture

Why is postgres taking computer user as login user?


I am trying to test wal2json on my system with Postgresql database. I have made changes in my postgresql.conf & pg_hba.conf file as shown in this link:

https://github.com/eulerto/wal2json

But when I am trying to create a test slot using postgres command, it is giving error:

C:\Program Files\PostgreSQL\12\bin>pg_recvlogical -d mydatabase --slot test_slot --create-slot -P wal2json
Password:
pg_recvlogical: error: could not connect to server: FATAL:  password authentication failed for user "LENOVO"

What is interesting here is that none of my postgres users are of name LENOVO. LENOVO is my laptop login name. Any idea how to sort this out?


Solution

  • Reason for this is that you did not specify user name in database connection string parameters. Linux pg_recvlogical man page says:

    -U user
    --username=user
    User name to connect as. Defaults to current operating system user name.
    

    You need to add database user name to your connection string.