0

My database.yml file does not seem to be picking up the environment variable correctly. When I put the password in directly, there are no issues, so I know it's not a password problem. I've also restarted the server.

Also, when I launch IRB on the server and type in ENV["DB_PASSWORD" it is returned:

    2.2.0 :001 > ENV["DB_PASSWORD"]
 => "tej-wir-alt-od-yirf-aj-yam-yis-ed-an-buc"

database.yml

production:
  database: myapp
  username: root
  password: <%= ENV["DB_PASSWORD"] %>
  host: localhost
  adapter: mysql2
  port: 3306
  pool: 15
  timeout: 5000

.bashrc

export MYSQL_DB=tej-wir-alt-od-yirf-aj-yam-yis-ed-an-buc
fatfrog
  • 2,118
  • 1
  • 23
  • 46

1 Answers1

4

You can set variable in .profile because it will load every time while you will reboot server.

You can add with following step:

open sudo nano ~/.profile

Then add variable

export DB_PASSWORD=tej-wir-alt-od-yirf-aj-yam-yis-ed-an-buc

Then reload profile with

. ~/.profile

And it will be work.

Sachin Gevariya
  • 1,167
  • 11
  • 25
  • Thanks! Moving the following from __.bashrc__ to __.prorfile__ worked for me (Rails 4.2, deploying to Apache on Digital Ocean) export RAILS_DATABASE_PASSWORD='mypassword' export SECRET_KEY_BASE=secretkey – 681234 Sep 28 '15 at 08:36
  • Worked with passenger gem. – khalidh Jun 14 '18 at 08:57