PSQL不检测.pgpass文件

时间:2017-12-05 09:01:29

标签: postgresql

我试过了

  1. 将.pgpass的权限设置为0600
  2. 确认.pgpass位于我用户的主目录(/home/brandon/.pgpass)
  3. 在pg_dumpall命令中使用-w
  4. 确认.pgpass中的数据是正确的
  5. 如果我一次又一次输入密码,自动备份的脚本(https://wiki.postgresql.org/wiki/Automated_Backup_on_Linux)就可以工作了,这就是我为所有命令添加-w的原因。由于某种原因,它不会读取.pgpass文件。

    有多条错误消息,但通常都是这样。

     pg_dumpall: could not connect to database "template1": FATAL:  password    authentication failed for user "postgres"
    

    致命:用户" postgres"

    的密码验证失败

    pg_pass文件:

    localhost:5432:my_db:postgres:password
    

    命令行:

    username@droplet:~/ProjectDir$ bash cronjob/db_backup/pg_backup.sh
    Making backup directory in /home/backups/database/postgresql/2017-12-06/
    
    
    Performing globals backup
    --------------------------------------------
    
    Globals backup
    cronjob/db_backup/pg_backup.sh: line 80: /home/backups/database/postgresql/2017-12-06/globals.sql.gz.in_progress: Permission denied
    pg_dumpall: could not connect to database "template1": fe_sendauth: no      password supplied
    
    [!!ERROR!!] Failed to produce globals backup
    
    
    Performing schema-only backups
    --------------------------------------------
    
    psql: fe_sendauth: no password supplied
    The following databases were matched for schema-only backup:
    
    
    
    
    Performing full backups
    --------------------------------------------
    
    psql: fe_sendauth: no password supplied
    
    All database backups complete!
    

1 个答案:

答案 0 :(得分:0)

您应该向pg_dumppg_dumpall提供实际的来电,以获得更详细的答案。

但是,从您的输出中我看到pg_dumpall(?)尝试连接到数据库template1,但在.pgpass文件中,唯一的数据库是my_db。< / p>

您必须为您尝试连接的所有数据库添加.pgpass条目。