我需要什么才能让pg_dumpall在没有密码的情况下工作? [英] What do I need for pg_dumpall to work without a password?

查看:333
本文介绍了我需要什么才能让pg_dumpall在没有密码的情况下工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我一直在努力设置 pg_dumpall ,但是如果不输入密码就无法使其正常工作。

So, I've been working on setting up a pg_dumpall but I cannot get it to work without entering a password.

我尝试过:

如何将密码传递到pg_dump?

,然后在此处输入密码:

and followed that to here:

http://www.postgresql.org/ docs / 8.4 / static / libpq-pgpass.html

仍然没有运气。

我的字符串和反应:

pg_dumpall -U user > /path/to_my/folder/test2.sql 
Password: 
Password: 
Password: 
Password: 
Password: 
Password: 
Password: 
Password: 
Password: 
Password: 

(在没有密码的情况下将其设为bash脚本)

(I will make this a bash script when I get it to work without a password)

我尝试使用 -w ,但是除非有密码,否则它不会转储。我还将该.pgpass文件放到了我的主目录中,并尝试将它们移到其他用户的主目录中。

I have tried to use -w but it won't dump unless there is a password. I also have put that .pgpass file in my home directory and have tried moving them to other user's home directories.

也许我只是没有正确设置文件,或者不知道可能在错误的位置,但是在这里是:

Maybe I just didn't make my file right or I don't know maybe it's in the wrong place but here that is:

*:*:*:user:password

任何帮助都会很棒。

谢谢

Any help would be great.
Thanks

推荐答案


我不确定PGPASSWORD环境变量在哪里

I'm not sure where the PGPASSWORD environment variable is

但是无论如何,像这样在本地使用它可能会更简单:

But anyway it may be simpler to use it locally like this:

PGPASSWORD=yourpassword pg_dumpall -U user > /path/to_my/folder/test2.sql 

这样做,变量将仅在持续时间内存在

Doing this, the variable will only exist for the duration of the dump.

编辑:有关此技术的安全性:

EDIT about the security of this technique:

@ Peter的评论可能与此postgres手册中的警告有关:

@Peter's comment is presumably related to this warning in postgres manual:


使用出于安全原因,不建议使用此环境变量,因为
某些操作系统允许非root用户通过ps查看进程环境
变量

Use of this environment variable is not recommended for security reasons, as some operating systems allow non-root users to see process environment variables via ps

但是某些操作系统相当模糊,并且环顾四周,似乎没有人认真地相信现代OS具有任何此类缺陷。

But some operating systems is pretty vague and looking around it appears that nobody seems to seriously believe that modern OSes have any such flaw.

security.SE涵盖了我认为有用的相关Q& A中的主题:

security.SE covers the topic in related Q&A's that I find useful:

正在通过流程环境安全地传递敏感数据?

Linux中的环境变量可访问性

我个人对此很满意,可以绕过postgres安全警告。但这不应该阻止任何人在自己的操作系统上进行自己的研究,尤其是在异国情调或过时的情况下。

Personally I'm happy enough with this to bypass the postgres security warning. But that shouldn't deter anyone to do his own research on his own operating system, especially if it's exotic or obsolete.

这篇关于我需要什么才能让pg_dumpall在没有密码的情况下工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆