How to set rails environment variables in database.yml file?
<p>On my local machine, I want to set environment variables for all of the sensitive information in the database.yml file. My file looks like this:</p>

<pre><code>default: &amp;default
  adapter: mysql2
  encoding: utf8
  pool: 5
  username: &lt;%= ENV['DATABASE_USERNAME'] %&gt; 
  password: &lt;%= ENV['DATABASE_PASSWORD'] %&gt;
  socket: &lt;%= ENV['SOCKET'] %&gt;

development:
  &lt;&lt;: *default
  database: &lt;%= ENV['DEVELOPMENT_DATABASE'] %&gt;

test:
  &lt;&lt;: *default
  database: #JetStreamIQ-2_0_test

production:
  &lt;&lt;: *default
  database: &lt;%= ENV['PRODUCTION_DATABASE'] %&gt;
  username: &lt;%= ENV['DATABASE_USERNAME'] %&gt; 
  password: &lt;%= ENV['DATABASE_PASSWORD'] %&gt;
</code></pre>

<p>I thought that I could just set these environment variables in my .bashrc file, but that doesn't seem to be working. My .bashrc file looks like this:</p>

<pre><code>export DATABASE_USERNAME="root"
export DATABASE_PASSWORD="*****"
export SOCKET="/var/run/mysqld/mysqld.sock"
export DEVELOPMENT_DATABASE="shoppe_development"
export PRODUCTION_DATABASE="#"
</code></pre>

<p>When I run my server with </p>

<pre><code>rails s
</code></pre>

<p>I get an error that says:</p>

<pre><code>Access denied for user 'root'@'localhost' (using password: YES)
</code></pre>

<p>I understand that there is a problem with the database username and password because of the way I've configured my database.yml file, but I'm just not sure what it is. </p>

<p>Is there something big I'm missing here? Any help would be much appreciated. </p>

<p>Thanks!</p>