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

时间:2015-07-29 20:46:44

标签: postgresql

我用这种方式创建了一个Postgres数据库:

createdb massive

然后我添加了一个角色:

sudo -iu postgres
psql -d massive
CREATE ROLE rob WITH SUPERUSER CREATEDB CREATEROLE LOGIN ENCRYPTED PASSWORD 'password';

我使用psql,然后\q用户exit退出postgres

现在我尝试登录:

psql -U rob -d massive -h localhost -W

在密码提示下输入password时,我明白了:

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

更新

\l中的

psql会返回:

                                  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

\du会返回此信息:

                             List of roles
 Role name |                   Attributes                   | Member of 
-----------+------------------------------------------------+-----------
 postgres  | Superuser, Create role, Create DB, Replication | {}
 rob       | Superuser, Create role, Create DB              | {}

0 个答案:

没有答案