2013-06-27 28 views
1

我想设置一个玩具数据库,我可以随意创建和销毁。我不想使用postgres用户以防我破坏重要的东西。我做了以下内容:psql:致命:角色“斯蒂芬”不存在

$ psql -h localhost -U postgres 
postgres=# \du 
         List of roles 
Role name |   Attributes    | Member of 
-----------+-----------------------------------+----------- 
postgres | Superuser, Create role, Create DB | {} 

postgres=# create user Stephen createdb; 
CREATE ROLE 
postgres=# \du 
        List of roles 
Role name |   Attributes    | Member of 
-----------+-----------------------------------+-----------  
postgres | Superuser, Create role, Create DB | {} 
stephen | Create DB       | {} 

postgres=# ^D\q 

后来,当我尝试连接,我收到以下错误:

$ psql -h localhost 
psql: FATAL: role "Stephen" does not exist 
$ psql -h localhost -U Stephen 
psql: FATAL: role "Stephen" does not exist 

这是没有意义的我。我可以看到用户,斯蒂芬,但它不会让我使用它。我错过了什么?

我在OS X Lion上使用psql 9.0.10。

+0

[您可能想查阅关于此事的优秀手册。](http://www.postgresql.org/docs/current/interactive/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS) –

回答

2

你试着写一个区分大小写:

$ psql -h localhost -U stephen 

当你的角色名与小s开始?

+0

嗯,似乎是这样。为什么当我明确使用一个大的'S'时,用小's'来创建它? –

+1

如果我“创建用户”Stephen“createdb;”(有趣的是,用双引号),那么它会创建一个具有正确大小写的用户。我接受你的答案。 –

+0

不好意思注意到你的第二个问题太晚了,很高兴你找到了答案:) – Francodi

1

登录区分大小写 - “Stephen”与“stephen”不同。