登录 PostgreSQL - 登录失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9539001/
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
Login to PostgreSQL - Login failed
提问by Ivan Z. Horvat
I installed psql and phpPgAdmin to my Ubuntu11.10 and don't know how to run it. What is the default username and password?
我在我的 Ubuntu11.10 上安装了 psql 和 phpPgAdmin,但不知道如何运行它。默认用户名和密码是什么?
回答by Joachim Isaksson
There is no default username and password without you creating one. The simplest possible setup is to follow these steps to set up your own user as a superuser.
没有您创建的默认用户名和密码。最简单的设置是按照以下步骤将您自己的用户设置为超级用户。
At a terminal prompt, create a postgres user with your own username
在终端提示下,使用您自己的用户名创建一个 postgres 用户
sudo -u postgres createuser --superuser $USER
Start the postgresql command prompt as your username but running as root since you didn't set a password yet;
以您的用户名启动 postgresql 命令提示符,但由于您尚未设置密码,因此以 root 身份运行;
sudo -u postgres psql
At the postgresql prompt, set your password;
在 postgresql 提示符下,设置您的密码;
\password $USER
After that, you should be able to log on just fine.
之后,您应该可以正常登录。
The setup is more thoroughly documented here.
设置在这里有更详尽的记录。
EDIT:
编辑:
If you get stuck not being able to authenticate automatically as the postgres
user, you may want to compare your /etc/postgresql/9.1/main/pg_hba.conf
(ie authentication config file) with the following lines from mine that works; you can get the uncommented ones using
如果您遇到无法以postgres
用户身份自动进行身份验证的问题,您可能需要将您的/etc/postgresql/9.1/main/pg_hba.conf
(即身份验证配置文件)与我的以下行进行比较;你可以使用
grep -v ^# pg_hba.conf
The "local" lines should be the essential ones in this case since you can't authenticate even from the same machine;
在这种情况下,“本地”行应该是必不可少的行,因为即使在同一台机器上也无法进行身份验证;
local all postgres peer
local all all peer
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
回答by Timur Sadykov
During the installation process you've probably missed steps:
在安装过程中,您可能错过了以下步骤:
Now we need to reset the password for the ‘postgres' admin account for the server, so we can use this for all of the system administration tasks. Type the following at the command-line (substitute in the password you want to use for your administrator account):
现在我们需要为服务器的“postgres”管理员帐户重置密码,以便我们可以将其用于所有系统管理任务。在命令行中键入以下内容(替换您要用于管理员帐户的密码):
sudo su postgres -c psql template1
template1=# ALTER USER postgres WITH PASSWORD 'password';
template1=# \q
That alters the password for within the database, now we need to do the same for the unix user ‘postgres':
这会改变数据库内的密码,现在我们需要为 unix 用户“postgres”做同样的事情:
sudo passwd -d postgres
sudo su postgres -c passwd
Now enter the same password that you used previously.
现在输入您之前使用的相同密码。
http://hocuspokus.net/2008/05/install-postgresql-on-ubuntu-804/
http://hocuspokus.net/2008/05/install-postgresql-on-ubuntu-804/