pg_dump密码认证失败

时间:2018-12-20 08:51:34

标签: postgresql pg-dump

我正在尝试在Windows中的postgres中安排每日备份例程。我已经创建了一个.bat文件和一个pgAgent作业。但是,我不断获得

与数据库“ postgres”的连接失败:致命:用户“ postgres”的密码身份验证失败

蝙蝠文件如下:

    @echo off
    set BACKUPDIR="C:/Backups/"
    set PGHOST="localhost"
    set PGUSER="postgres"
    set PGBIN="C:/Program Files/PostgreSQL/10/bin/"
   for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (
     set dow=%%i
     set month=%%j
     set day=%%k
     set year=%%l
   )
   set datestr=%month%_%day%_%year%
   echo datestr is %datestr%
   set BACKUP_FILE="backupdb_%datestr%"
   echo backup file name is %BACKUP_FILE%
   SET PGPASSWORD="mypassword"
   echo on
   %PGBIN%pg_dump -h localhost -U postgres -F  c -p 5432 -b -v -f 
    "%BACKUPDIR%%BACKUP_FILE%.compressed" postgres

pgpass.conf看起来像这样:

localhost:5432:postgres:postgres:mypassword

pg_host.conf文件如下所示(我删除了地址)

# IPv4 local connections:
host    all             all                         md5
# IPv6 local connections:
host    all             all                         md5

0 个答案:

没有答案