【问题标题】:psql: FATAL: role "Stephen" does not existpsql:致命:角色“斯蒂芬”不存在
【发布时间】:2013-06-27 21:08:39
【问题描述】:

我正在尝试设置一个我可以随意创建和销毁的玩具数据库。我不想使用postgres 用户,以防我破坏了一些重要的东西。我做了以下事情:

$ 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。

【问题讨论】:

标签: postgresql osx-lion


【解决方案1】:

您是否尝试将其写成区分大小写:

$ psql -h localhost -U stephen

因为您的角色名称以小 s 开头?

【讨论】:

  • 嗯,好像是这样。当我明确使用大 S 时,为什么它会使用小 s 创建它?
  • 如果我这样做create user "Stephen" createdb;(有趣的是,带有双引号),那么它会创建一个具有正确大小写的用户。我接受你的回答。
  • 抱歉发现你的第二个问题太晚了,很高兴你找到了答案:)
  • @StephenRasku:未加引号的标识符被折叠成小写,双引号的标识符保留它们的大小写。
【解决方案2】:

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

【讨论】:

    猜你喜欢
    • 2015-03-28
    • 2013-02-24
    • 2018-02-18
    • 1970-01-01
    • 2017-03-08
    • 2014-03-15
    • 2013-05-21
    相关资源
    最近更新 更多