pgAgent 无法连接数据库:'fe_sendauth:未提供密码'(在 Windows7 中)

ara*_*ayo 2 windows-7 pgagent postgresql-9.3

请帮助我.. 我有一些关于 pgAgent 的问题。

[环境]

DB : PostgreSQL 9.3

OS : Window 7

OS login ID : someid@mail.com

pgAdmin login ID : postgres

pgAgent user : postgres 

pgAgent schema belongs to: postgres DB

DB that I'll treat : testDB  (In Step configuration, I specified 'testDB' as Database.
                   Connection type is 'local'. Connection string is empty.)

DB server : local machine (my laptop computer)
Run Code Online (Sandbox Code Playgroud)

我安排了 pgAgent 作业,但无法连接数据库。

输出消息( pgAdmin>Statistics )

[Warning] Couldn't get a connection to the database (pgAgent)
Run Code Online (Sandbox Code Playgroud)

(什么数据库?有 2 个 DB。'postgres' 和 'testDB'。我会处理 'testDB'。然后无法连接到哪个数据库?)

窗口事件查看器

Failed to create new connection to database 'testDB':'fe_sendauth: no password supplied'
Run Code Online (Sandbox Code Playgroud)

我的 pgpass.conf

localhost:5432:postgres:postgres:[pgAdmin password for postgres]
localhost:5432:testDB:postgres:[pgAdmin password for postgres]
Run Code Online (Sandbox Code Playgroud)

我的 pg_hba.conf

@remove-line-for-nolocal@# "local" is for Unix domain socket connections only

@remove-line-for-nolocal@local   all             all                                     @authmethodlocal@
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 @authmethodhost@
# Allow replication connections from localhost, by a user with the
# replication privilege.
@remove-line-for-nolocal@#local   replication     @default_username@                                @authmethodlocal@
#host    replication     @default_username@        127.0.0.1/32            @authmethodhost@
#host    replication     @default_username@        ::1/128                 @authmethodhost@
Run Code Online (Sandbox Code Playgroud)

我的 pgAgent 命令选项( Service>pgAgent>Property>General 选项卡)

C:\Program Files (x86)\pgAgent\bin\pgagent.exe RUN pgAgent host=localhost port=5432 user=postgres dbname=postgres
Run Code Online (Sandbox Code Playgroud)

pgAgent 服务登录 ID(服务>pgAgent>属性>登录选项卡)

id : someid@mail.com

pwd : [ someid@mail.com's password ]
Run Code Online (Sandbox Code Playgroud)

[结论]

pgpass.conf 中的密码设置对于我所知道的任何事情似乎都是错误的。或者pg_hba.conf 或者Services>pgAgent>Logon 其实登录ID..真不明白怎么回事^^

提前感谢您的帮助^^

ara*_*ayo 5

美好的一天...我解决了它^^

[解决方案]

I made other OS login ID. (NOT need to be 'postgres' !!)
And put pgpass.conf in that ID's AppData\Roaming\postgresql
Run Code Online (Sandbox Code Playgroud)

[原因]

pgAgent could not find pgpass.conf in login ID's directory.
Run Code Online (Sandbox Code Playgroud)

我说我的操作系统登录 ID 是someid@mail.com。

但是 someid@mail.com 的真实姓名(C:\Users 中的文件夹名称)是'SOME NAME TEST'

那不一样 !!

当我在服务中检查登录 ID 时,pgAgent 的登录 ID 是“.\someid@mail.com”。

我猜 pgAgent 试图在“ C:\Users\someid@mail.com\AppData\Roaming\postgresql ”中找到 pgpass.conf 。

但是没有这样的目录。!!

我的 pgpass.conf 在'C:\Users\SOME NAME TEST\AppData\Roaming\postgresql'

我以随意的方式创建了另一个操作系统 ID 'anyname'。(控制面板>帐户管理。)

login ID : anyname

real name : anyname ( C:\Users\anyname )
Run Code Online (Sandbox Code Playgroud)

那是一样的!!^^

并将 pgpass.conf 放在'C:\Users\anyname\AppData\Roaming\postgresql'

然后在服务中将 pgAgent 的登录 ID 更改为 '.\anyname'。

现在效果很好^^