登录PostgreSQL - 登录失败

Iva*_*vat 20 postgresql ubuntu phppgadmin

我在我的Ubuntu11.10上安装了psql和phpPgAdmin,不知道如何运行它.什么是默认用户名和密码?

Joa*_*son 45

没有您创建的用户名和密码,没有默认用户名和密码.最简单的设置是按照以下步骤以超级用户身份设置您自己的用户.

在终端提示符下,使用您自己的用户名创建一个postgres用户

sudo -u postgres createuser --superuser $USER
Run Code Online (Sandbox Code Playgroud)

以您的用户名启动postgresql命令提示符,但由于您尚未设置密码,因此以root用户身份运行;

sudo -u postgres psql
Run Code Online (Sandbox Code Playgroud)

在postgresql提示符下,设置密码;

\password $USER
Run Code Online (Sandbox Code Playgroud)

在那之后,你应该能够登录就好了.

此处的设置更全面.

编辑:

如果您无法以postgres用户身份自动进行身份验证,您可能需要将您的/etc/postgresql/9.1/main/pg_hba.conf(即身份验证配置文件)与我的以下行进行比较; 你可以使用未经注释的那些

grep -v ^# pg_hba.conf
Run Code Online (Sandbox Code Playgroud)

在这种情况下,"本地"线应该是必不可少的,因为即使是在同一台机器上也无法进行身份验证.

local   all             postgres                                peer
local   all             all                                     peer
host    all             all             127.0.0.1/32            md5
host    all             all             ::1/128                 md5
Run Code Online (Sandbox Code Playgroud)


Tim*_*kov 4

在安装过程中您可能错过了以下步骤:

\n\n
\n

现在我们需要重置服务器的 \xe2\x80\x98postgres\xe2\x80\x99 管理员帐户的密码,以便我们可以使用它来执行所有系统管理任务。在命令行中键入以下内容(替换为您要用于管理员帐户的密码):

\n
\n\n
sudo su postgres -c psql template1\ntemplate1=# ALTER USER postgres WITH PASSWORD \'password\';\ntemplate1=# \\q\n
Run Code Online (Sandbox Code Playgroud)\n\n
\n

这会更改数据库内的密码,现在我们需要对 unix 用户 \xe2\x80\x98postgres\xe2\x80\x99 执行相同的操作:

\n
\n\n
sudo passwd -d postgres\nsudo su postgres -c passwd\n
Run Code Online (Sandbox Code Playgroud)\n\n
\n

现在输入您之前使用的相同密码。

\n
\n\n

http://hocuspokus.net/2008/05/install-postgresql-on-ubuntu-804/

\n