Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8565229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:22:41+00:00 2026-06-11T17:22:41+00:00

I don’t want to check my production username and password into version control for

  • 0

I don’t want to check my production username and password into version control for security purposes. If I do check it in, everyone will be able to see it. Here is the database.yml file as it is checked into version control:

# /config/database.yml:
production:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: desk_production
  pool: 5
  username: root
  password: password_here

As you can see, ‘password_here’ is checked in as the password – but this is an invalid password if ever checked against the production database. I basically have two options other than checking my live password into version control:

  1. Save the real database.yml file on the production server in a directory above the application root. Make a capistrano recipe to create a symbolic lync to that file when the app is deployed – this would basically overwrite the database.yml file checked into version control.
  2. Save the real database.yml file (just like in option #1), but instead of making a symbolic lync, import it into database.yml file checked into version control. This will allow the system to reference the existing file on the server each time the app is deployed without deployers worrying about changing the password or creating symbolic lyncs. Also, I could have the permanent database.yml file which stays on the server set so the deployer can’t see it…

I like the second option the most, it would basically look something like this:

# Config file permanently stored on the web server:
# ../app_root/database.yml (notice this is one level up from the app so it doesn't get written over)

# This is the file checked into version control:
production:
 << ../app_root/database.yml
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:22:43+00:00Added an answer on June 11, 2026 at 5:22 pm

    Or you can read it from an environment variable:

    production:
      ...
      password: <%= ENV['DB_PASSWORD'] %>
      ...
    

    You just need to make sure that the user that starts your rails app has the environment variable set in their profile so it will be available in the ENV hash. For example, I often use a deployer user to deploy apps via capistrano, so I have export DB_PASSWORD=the_password set in that user’s ~/.bashrc file (of whatever is the proper place for it to go for the system you’re deploying to).

    This way, it’s part of your source control in the sense that everyone will know where to set the password, but the password itself is not part of your source control. You’ll need to keep that secret, obviously.

    It wasn’t immediately obvious to me either, but .yml files can have embedded ruby in them, similar to .erb templates, though I have run into situations where things like this didn’t work when the environment variable itself had certain special characters in it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Don't be frightened, its a very basic code. Just wanted to check with you
I don't want my user to even try downloading something unless they have Wi-Fi
Don't have much to say, just can get into the event handler. XAML: <Grid>
Don't know a whole lot about streams. Why does the first version work using
Don't know if this is the right place to ask this, but I will
Don't know if I'm over-thinking this or not.. but I'm trying to be able
Don't want to pay for dedicated server for dev work. I don't want to
(Don't care about the version. IE or not IE.)
Don't get me wrong, I want them to get saved. But I always thought
Don't want to sort the entries. using this does not preserve the order as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.