为什么 postgres 将计算机用户作为登录用户?

Why is postgres taking computer user as login user?

我正在尝试使用 Postgresql 数据库在我的系统上测试 wal2json。我已在我的 postgresql.conf & pg_hba.conf 文件中进行了更改,如此 link:

所示

https://github.com/eulerto/wal2json

但是当我尝试使用 postgres 命令创建测试槽时,出现错误:

C:\Program Files\PostgreSQL\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"

这里有趣的是 none 我的 postgres 用户的名字是 LENOVO。 LENOVO 是我的笔记本电脑登录名。知道如何解决这个问题吗?

原因是您没有在数据库连接字符串参数中指定用户名。 Linux pg_recvlogical 手册页说:

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

您需要将数据库用户名添加到您的连接字符串中。