postgresql postgres 的密码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9832648/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
password for postgres
提问by Doboy
In the short version of postgres' installing it tell me to do the following
在 postgres 安装的简短版本中,它告诉我执行以下操作
./configure
gmake
su
gmake install
adduser postgres
mkdir /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &
/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test
Now I created the postgres
user, but it sometimes asks for my credentials for that user
. Is there a default password for the postgres
user? Why do I even need to make another user
?
现在我创建了postgres
用户,但它有时会要求我提供该用户的凭据user
。用户是否有默认密码postgres
?为什么我什至需要制作另一个user
?
回答by Doboy
What's the default superuser username/password for postgres after a new install?:
新安装后 postgres 的默认超级用户用户名/密码是什么?:
CAUTIONThe answer about changing the UNIX password for "postgres" through "$ sudo passwd postgres" is not preferred, and can even be DANGEROUS!
This is why: By default, the UNIX account "postgres" is locked, which means it cannot be logged in using a password. If you use "sudo passwd postgres", the account is immediately unlocked. Worse, if you set the password to something weak, like "postgres", then you are exposed to a great security danger. For example, there are a number of bots out there trying the username/password combo "postgres/postgres" to log into your UNIX system.
What you should do is follow Chris James's answer:
sudo -u postgres psql postgres # \password postgres Enter new password:
To explain it a little bit...
注意通过“$ sudo passwd postgres”更改“postgres”的 UNIX 密码的答案不是首选,甚至可能是危险的!
这就是为什么:默认情况下,UNIX 帐户“postgres”是锁定的,这意味着它不能使用密码登录。如果您使用“sudo passwd postgres”,该帐户将立即解锁。更糟糕的是,如果您将密码设置为弱密码,例如“postgres”,那么您将面临极大的安全隐患。例如,有许多机器人尝试使用用户名/密码组合“postgres/postgres”来登录您的 UNIX 系统。
您应该做的是遵循Chris James的回答:
sudo -u postgres psql postgres # \password postgres Enter new password:
稍微解释一下……
回答by MAbraham1
Set the default password in the .pgpass file. If the server does not save the password, it is because it is not set in the .pgpass file, or the permissions are open and the file is therefore ignored.
在 .pgpass 文件中设置默认密码。如果服务器不保存密码,是因为.pgpass文件中没有设置密码,或者权限打开导致文件被忽略。
Read more about the password file here.
Also, be sure to check the permissions: on *nix systems the permissions on .pgpass must disallow any access to world or group; achieve this by the command chmod 0600 ~/.pgpass. If the permissions are less strict than this, the file will be ignored.
另外,请务必检查权限:在 *nix 系统上,.pgpass 上的权限必须禁止对世界或组的任何访问;通过命令 chmod 0600 ~/.pgpass 实现这一点。如果权限不那么严格,则该文件将被忽略。
Have you tried logging-in using PGAdmin? You can save the password there, and modify the pgpass file.
您是否尝试过使用 PGAdmin 登录?您可以在那里保存密码,并修改 pgpass 文件。