title: Rails: Production Rails console won't start
body: <p>Everything works fine on my OS X development laptop.</p>
  
  <p>Deploy the app to production and it runs and displays data as expected.</p>
  
  <p>However, when I try to run the Rails <strong>console</strong> on the production server I get an error...</p>
  
  <pre><code>$ rails console -e production
  /opt/deployed_rails_apps/con_app_rails_3/shared/bundle/ruby/1.9.1/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:
      in `connect': Can't connect to local MySQL server through socket 
          '/tmp/mysql.sock' (2) (Mysql2::Error)
  
      from /opt/deployed_rails_apps/con_app_rails_3/shared/bundle/ruby/1.9.1/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `initialize'
      from /opt/deployed_rails_apps/con_app_rails_3/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
  </code></pre>
  
  <p>I tried removing <code>socket: /tmp/mysql.sock</code> from database.yml -- same result.</p>
  
  <p>Although the app runs, I do need to be able to access the console in production as well to perform certain tasks.</p>
  
  <p>I am able to connect to the MySQL server using the MySQL command line client.</p>
  
  <hr>
  
  <p>ruby 1.9.3p125</p>
  
  <p>Rails 3.2.2</p>
  
  <p>mysql2 gem 0.3.11</p>
  
  <p>MySQL server:  5.1.61</p>
  
  <p>Production host: Linux 2.6.32-220.4.2.el6.x86_64</p>
  
  <p>database.yml</p>
  
  <pre><code>development:
    adapter: mysql2
    encoding: utf8
    reconnect: false
    database: con_app_rails_3_development
    pool: 5
    username: root
    password:
    socket: /tmp/mysql.sock
  
  test:
    adapter: mysql2
    encoding: utf8
    reconnect: false
    database: con_app_rails_3_test
    pool: 5
    username: root
    password:
    socket: /tmp/mysql.sock
  
  production:
    adapter: mysql2
    encoding: utf8
    reconnect: false
    host: dbhost
    database: con_app_rails_3_production
    pool: 5
    username: xxxx
    password: xxxx
    socket: /tmp/mysql.sock
  </code></pre>