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」不同。