Postgresql Postgres:使用超级用户和密码创建数据库

Postgresql Postgres:使用超级用户和密码创建数据库,postgresql,Postgresql,我这样创建了一个Postgres数据库: createdb massive 然后我添加了一个角色: sudo -iu postgres psql -d massive CREATE ROLE rob WITH SUPERUSER CREATEDB CREATEROLE LOGIN ENCRYPTED PASSWORD 'password'; 我用\q退出psql,然后退出用户postgres 现在我尝试登录: psql -U rob -d massive -h localhost -W 在

我这样创建了一个Postgres数据库:

createdb massive
然后我添加了一个角色:

sudo -iu postgres
psql -d massive
CREATE ROLE rob WITH SUPERUSER CREATEDB CREATEROLE LOGIN ENCRYPTED PASSWORD 'password';
我用
\q
退出
psql
,然后退出
用户
postgres

现在我尝试登录:

psql -U rob -d massive -h localhost -W
在密码提示下输入密码时,我得到以下信息:

psql: FATAL:  password authentication failed for user "rob"
更新:

psql
中的
\l
返回以下内容:

                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 massive   | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
                             List of roles
 Role name |                   Attributes                   | Member of 
-----------+------------------------------------------------+-----------
 postgres  | Superuser, Create role, Create DB, Replication | {}
 rob       | Superuser, Create role, Create DB              | {}
\du
返回以下内容:

                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 massive   | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
                             List of roles
 Role name |                   Attributes                   | Member of 
-----------+------------------------------------------------+-----------
 postgres  | Superuser, Create role, Create DB, Replication | {}
 rob       | Superuser, Create role, Create DB              | {}

如果指定
encrypted
,则您提供的密码值(
'password'
部分)必须已经加密。当您在
CREATE ROLE
语句中以纯文本形式提供密码时,必须删除
encrypted
关键字。在没有
encrypted
关键字的情况下尝试了密码,但仍然不起作用。您能否检查pg_hba.conf以确保密码身份验证是一种可接受的身份验证方法?未列出密码。我添加了这一行:
localall-all-password
并运行了
sudo/etc/init.d/postgrestart
。但是仍然没有成功。我无法使用
psql
作为
postgres:postgres
登录。如果指定
encrypted
则您提供的密码(密码部分)的值必须已经加密。当您在
CREATE ROLE
语句中以纯文本形式提供密码时,必须删除
encrypted
关键字。在没有
encrypted
关键字的情况下尝试了密码,但仍然不起作用。您能否检查pg_hba.conf以确保密码身份验证是一种可接受的身份验证方法?未列出密码。我添加了这一行:
localall-all-password
并运行了
sudo/etc/init.d/postgrestart
。但是仍然没有成功。我无法使用
psql
as
postgres:postgres
登录。