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

问题描述 投票:2回答:2

请帮帮我。我对pgAgent有一些疑问。

[环境]

DB : PostgreSQL 9.3

OS : Window 7

OS login ID : [email protected]

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)

我计划了pgAgent作业,但是无法连接数据库。

输出消息(pgAdmin> Statistics]

[Warning] Couldn't get a connection to the database (pgAgent)

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

Windows事件查看器

Failed to create new connection to database 'testDB':'fe_sendauth: no password supplied'

My pgpass.conf

localhost:5432:postgres:postgres:[pgAdmin password for postgres]
localhost:5432:testDB:postgres:[pgAdmin password for postgres]

我的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@

我的pgAgent命令选项(服务> pgAgent>“属性”>“常规”选项卡)

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

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

id : [email protected]

pwd : [ [email protected]'s password ]

[结论]

我知道的所有内容,在pgpass.conf中的密码设置似乎都是错误的。或pg_hba.conf或服务> pgAgent>登录中的登录ID其实..我真的不明白怎么了。^^

谢谢您的帮助^^

windows-7 postgresql-9.3 pgagent
2个回答
4
投票

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

[解决方案]

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

[原因]

pgAgent could not find pgpass.conf in login ID's directory.

我说过我的操作系统登录ID是[email protected]

但是[email protected]的真实姓名(C:\ Users中的文件夹名称)是'SOME NAME TEST'

与众不同!

当我检查服务中的登录ID时,pgAgent的登录ID为'。\ [email protected]'。

我想pgAgent试图在'C:\ Users \ [email protected] \ AppData \ Roaming \ postgresql'中找到pgpass.conf。

但是没有这样的目录。!

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

我随意地将另一个OS ID命名为“ anyname”。 (控制面板>帐户管理。)

login ID : anyname

real name : anyname ( C:\Users\anyname )

是一样的! ^^

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

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

现在很好用了^^


1
投票
SET PGPASSWORD=<PassWord>
pg_dump -h <HostName> -p 5432 -U <UserName> -F c -b -v -f %BACKUP_FILE% <DATABASENAME>

来源:https://wiki.postgresql.org/wiki/Automated_Backup_on_Windows

© www.soinside.com 2019 - 2024. All rights reserved.