Rails Capistrano部署PG :: ConnectionBad:严重:密码验证失败

时间:2019-04-24 10:45:51

标签: ruby-on-rails postgresql deployment capistrano production-environment

deploy:migrating
      01 /usr/local/rvm/bin/rvm default do bundle exec rake db:migrate
      01 rake aborted!
      01 PG::ConnectionBad: FATAL:  password authentication failed for user "customuser"
...
Tasks: TOP => db:migrate

1)我通常可以在customuser下登录psql 2)服务器RAILS_ENV=production rake db:migrate上的命令正在运行 3)database.yml:

production:
  <<: *default
  database: app_production
  host: localhost
  username: customuser
  password: mypassword

4)/etc/postgresql/10/main/pg_hba.conf:

# "local" is for Unix domain socket connections only
local   all             all                                     md5

还尝试了peer

2 个答案:

答案 0 :(得分:0)

已解决。需要添加宝石https://github.com/capistrano-plugins/capistrano-postgresql

library(tidyverse) df %>% group_by(Group) %>% mutate(Surv_Prob1 = c(Surv_Prob[1], diff(Surv_Prob)), Surgery = factor(Surgery, levels = rev(unique(Surgery)))) %>% ggplot() + aes(Group, Surv_Prob1, fill = Surgery, label = Surv_Prob) + geom_bar(stat = "identity") + geom_text(size = 3, position = position_stack(vjust = 0.5))

df <- structure(list(Surgery = structure(c(1L, 2L, 3L, 4L, 1L, 2L, 
3L, 4L), .Label = c("CV", "Hip", "Knee", "QFox"), class = "factor"), 
Surv_Prob = c(0.5113, 0.6619, 0.6665, 0.7054, 0.5113, 0.6629, 
0.6744, 0.7073), Group = structure(c(1L, 1L, 1L, 1L, 2L, 
2L, 2L, 2L), .Label = c("Diabetic", "Non-Diabetic"), class = 
"factor")), class = "data.frame", row.names = c(NA, -8L))

答案 1 :(得分:0)

当尝试使用Capistrano部署Rails应用程序并到达此处时,我遇到了相同的错误消息。

就我而言,我已将虚拟密码硬编码到环境变量中:

DATABASE_URL=postgresql://deploy:PASSWORD@127.0.0.1/myapp

当然,PASSWORD应该是实际密码。

如果我的愚蠢帮助别人,我会留在这里。