windows Postgres 的默认密码是什么

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27107557/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 18:50:55  来源:igfitidea点击:

What is the default password for Postgres

windowspostgresql

提问by AlexC

I have just install Postgres 9.3 on Windows 7. The installation completed successfully. It has never asked me to provide the password for postgres user.

我刚刚在 Windows 7 上安装了 Postgres 9.3。安装成功完成。它从未要求我提供 postgres 用户的密码。

The service postgresql-x64-9.3 is up and running. However, I cannot connect: I do not not know the password. I've found the following answer, but it did not help:

服务 postgresql-x64-9.3 已启动并正在运行。但是,我无法连接:我不知道密码。我找到了以下答案,但没有帮助:

similar question on Ubuntu

Ubuntu 上的类似问题

回答by Craig Ringer



WARNING: trustmeans exactly that. Anyone who can connect to the PostgreSQL server can control it. If you set trustmode that allows superusers like user postgres(or allusers) to connect, they get total control of your PostgreSQL and can probably run shell commands too. You should usually only use it to change the passwordthen restore the configuration back to the auth mode you were using before.

警告trust正是这个意思。任何可以连接到 PostgreSQL 服务器的人都可以控制它。如果您设置trust允许超级用户postgres(如用户all)连接的模式,他们将完全控制您的 PostgreSQL,并且可能也可以运行 shell 命令。您通常应该只使用它来更改密码,然后将配置恢复到您之前使用的身份验证模式。



If you used an unattended installer script, the password will be in the script or associated config file.

如果您使用无人参与的安装程序脚本,密码将在脚本或关联的配置文件中。

Otherwise, treat it the same as if you lost/forgot the password rather than never knowing it:

否则,将其视为丢失/忘记密码而不是永远不知道它:

  • Edit pg_hba.conf, setting the auth mode to trustinstead of the default md5
  • In the Services control panel restart the PostgreSQL service
  • Connect with psqlor PgAdmin or whatever
  • ALTER USER postgres PASSWORD 'mynewpassword';
  • Edit pg_hba.confagain and set the auth mode back to md5
  • Restart PostgreSQL again
  • 编辑pg_hba.conf,将 auth 模式设置为trust而不是默认md5
  • 在服务控制面板中重启 PostgreSQL 服务
  • 连接psql或 PgAdmin 或其他
  • ALTER USER postgres PASSWORD 'mynewpassword';
  • pg_hba.conf再次编辑并将身份验证模式设置回md5
  • 再次重启 PostgreSQL

pg_hba.confis in your data directory. By default it'll be %PROGRAMFILES%\PostgreSQL\9.3\data.

pg_hba.conf位于您的数据目录中。默认情况下它将是%PROGRAMFILES%\PostgreSQL\9.3\data.

To edit it you'll have to use the security tab to give yourself read/write permissions (via a UAC prompt). This might require you to set yourself as the owner of the file.

要编辑它,您必须使用安全选项卡为自己授予读/写权限(通过 UAC 提示)。这可能需要您将自己设置为文件的所有者。



On unix systems it's more secure to prepend a

在 unix 系统上,预先添加一个更安全

local all all peer

line to pg_hba.confand then sudo -u postgres psql(assuming your PostgreSQL server runs as user postgres) to get an interactive psqlsession without using a password. That way you don't have to use trust.

line topg_hba.conf然后sudo -u postgres psql(假设您的 PostgreSQL 服务器以 userpostgres身份运行)以在psql不使用密码的情况下获得交互式会话。这样你就不必使用trust.

回答by lalit bhadouria

go to control >> computer management >> Locaol users and group >> users >> right click on openpgsvc >> set password. after that now you can access with this password on openpgsvc

转到控制>>计算机管理>>本地用户和组>>用户>>右键单击openpgsvc>>设置密码。之后,现在您可以在 openpgsvc 上使用此密码访问