PostgreSQL 的默认用户名和密码是什么?

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

What is the default username and password for PostgreSQL?

postgresqlpostgresql-8.4

提问by Abhishek

I am working on an open source application that has PostgreSQL as its default DBMS. Now when I install it on my system, its configuration is so that PostgreSQL also gets installed with it.

我正在开发一个以 PostgreSQL 作为默认 DBMS 的开源应用程序。现在当我在我的系统上安装它时,它的配置是为了 PostgreSQL 也被安装。

My problem is with getting an access to the installed PostgreSQL database. The database that gets created during installation is named iviewdb.

我的问题是访问已安装的 PostgreSQL 数据库。在安装过程中创建的数据库名为iviewdb.

I read at many forums that the default super-user is postgresbut when I try to get an access to the database using this username through command-prompt, it prompts me for password that I don't have.

我在许多论坛上读到默认超级用户是,postgres但是当我尝试通过命令提示符使用此用户名访问数据库时,它提示我输入我没有的密码。

What I wanted to know from is where in the PostgreSQL installation directory the default username and password with the port number to access the database is stored. I have even tried changing the pg_hba.conffile, but that creates problem with the application and it won't start then.

我想知道的是 PostgreSQL 安装目录中存储默认用户名和密码以及访问数据库的端口号的位置。我什至尝试更改pg_hba.conf文件,但这会导致应用程序出现问题,并且无法启动。

Do you have any idea to find the password for this database? I am working on Windows environment.

你知道找到这个数据库的密码吗?我在 Windows 环境下工作。

回答by Joe

The password isn't stored in an easily recoverable manner, and if you change the password, the application may not be able to access the database properly. You may find the password in the application settings or docs, though.

密码不是以易于恢复的方式存储的,如果您更改密码,应用程序可能无法正确访问数据库。不过,您可以在应用程序设置或文档中找到密码。

If you decide to risk changing the postgres user's password, stop the application and postgres service, then edit pg_hba.conf, Add (or change if it already exists) a line (if it doesn't exist, add it before any other "host...." lines)

如果您决定冒险更改 postgres 用户的密码,请停止应用程序和 postgres 服务,然后编辑 pg_hba.conf,添加(如果已经存在则更改)一行(如果不存在,则在任何其他“主机”之前添加它....”行)

host   all   all   127.0.0.1/32   trust

And restart the PostgreSQL service. That should give you access from localhost, where you could change the postgres user's password, or add yourself another user with the permissions you want. Then set the pg_hba.conf file back the way it was and restart.

并重启 PostgreSQL 服务。这应该可以让您从 localhost 访问,您可以在其中更改 postgres 用户的密码,或者为自己添加另一个具有所需权限的用户。然后将 pg_hba.conf 文件设置回原来的样子并重新启动。