【问题标题】:Changed computer, can't access rails app - psql database更换计算机,无法访问 rails 应用程序 - psql 数据库
【发布时间】:2017-02-18 20:47:41
【问题描述】:

更换 mac 电脑后,我无法在本地运行现有的 rails 应用程序。我在新计算机上从 Time Machine 备份中进行了还原,因此我不必重新添加所有应用程序和信息。当我尝试运行我的应用程序时,我收到以下错误

Internal Server Error
FATAL: role "<username>" does not exist

我很确定这与 PSQL 数据库有关,因为当我键入时

psql <database name>

我收到以下错误

psql: FATAL:  role "<username>" does not exist

我试过了

sudo su - postgres

并收到以下错误

su: unknown login: postgres

我不知道这个错误是因为我不知道 postgres 的密码还是 postgres 角色不存在。我不知道从这里做什么。有什么建议吗?

【问题讨论】:

    标签: ruby-on-rails macos postgresql psql


    【解决方案1】:
    1. 查找路径:which createuser
    2. 创建 postgres 用户:PATH_FROM_ABOVE/createuser -s postgres
    3. 连接psql -U postgres -d postgres
    4. 创建缺少的角色:create user "&lt;username&gt;" password '&lt;password&gt;';

    【讨论】:

    • 第一步将显示createuser 的路径 - 其余的都一样
    • 那行不通。这是错误createuser: could not connect to database postgres: FATAL: role "&lt;username&gt;" does not exist
    • 我不能确定,所以我尝试卸载 postgres 并重新安装(查看 Bew)。这也没有帮助,我现在有一个新错误could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
    • 更新:我再次使用 brew 卸载并重新安装了 postgresql,它现在可以工作了!
    猜你喜欢
    • 2011-12-09
    • 2012-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-07
    • 1970-01-01
    • 2012-06-09
    • 2015-01-14
    相关资源
    最近更新 更多