gpt4 book ai didi

ruby - 带有 sinatra 的 Postgres 在部署时产生 "database does not exist"

转载 作者:行者123 更新时间:2023-11-29 13:33:47 24 4
gpt4 key购买 nike

在通过 Capistrano 部署(首次部署)我的 Sinatra 项目时,我在首次迁移期间发现了问题(我正在使用 activerecord):

FATAL: database "root@127.0.0.1/app" does not exist

但它在服务器(ubuntu)上连接良好

root@wallget:~# psql -U root -d app -h 127.0.0.1
psql (8.4.17)
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
Type "help" for help.

app=> \q

在我的应用程序配置中:

db = URI.parse(ENV['DATABASE_URL'] || 'postgres:///root@127.0.0.1/app')

ActiveRecord::Base.establish_connection(
:adapter => db.scheme == 'postgres' ? 'postgresql' : db.scheme,
:host => db.host,
:username => db.user,
:password => db.password,
:database => db.path[1..-1],
:encoding => 'utf8'
)

这是我的 pg_hba.conf 行:

# IPv4 local connections:
host all all 127.0.0.1/32 trust

可能是什么问题?我正在我的 vps 上部署,而不是 Heroku。

最佳答案

尝试 postgres://root@127.0.0.1/app(两个斜杠而不是三个)

关于ruby - 带有 sinatra 的 Postgres 在部署时产生 "database does not exist",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17948021/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com