Connect to Production Database - Explicit password on database.yml?

37 views
Skip to first unread message

Leandro França

unread,
Jun 1, 2015, 2:54:05 PM6/1/15
to rubyonra...@googlegroups.com
Hi there,

What is a good way to setup connection to production database?
Do I really need to keep production password on database.yml file? Are there any other ways?

Thanks in advance,
Leandro

Colin Law

unread,
Jun 1, 2015, 3:03:22 PM6/1/15
to rubyonra...@googlegroups.com
On 1 June 2015 at 19:54, Leandro França <leandroay...@gmail.com> wrote:
> Hi there,
>
> What is a good way to setup connection to production database?
> Do I really need to keep production password on database.yml file? Are there
> any other ways?

In database.yml use something like
password: <%= ENV['MY_DATABASE_PASSWORD'] %>
and externally setup an environment variable MY_DATABASE_PASSWORD

I believe that is what
rails new ...
generates automatically. Did it not for you?

Colin

Leandro França

unread,
Jun 1, 2015, 3:25:31 PM6/1/15
to rubyonra...@googlegroups.com
It looks it did, but my app still is not connecting.
Looks like I'm missing something.

I created the database with:
rake db:create RAILS_ENV=production

But when I try to run the app, production.log gives me the error:

PG Peer authentication failed for user "myusername" 

I've tried to add host:localhost to my config/database.yml, and now it gives me this error:
PG::ConnectionBad (fe_sendauth: no password supplied
 


Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsZOyGNzao2n5qHqLiqSoVJEcj1E_mG79xgfewPrWHdKA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Colin Law

unread,
Jun 1, 2015, 4:29:03 PM6/1/15
to rubyonra...@googlegroups.com
On 1 June 2015 at 20:25, Leandro França <leandro...@pobox.com> wrote:
> It looks it did, but my app still is not connecting.
> Looks like I'm missing something.

Try first with the password explicitly in database.yml, then when that
is working use an environment variable instead.

Colin
Reply all
Reply to author
Forward
0 new messages