ActiveRecord::AdapterNotSpecified: 'production' database is not configured.

I was getting the error: ActiveRecord::AdapterNotSpecified: 'production' database is not configured. Available: [development]. You must have the database.yml that has a configuration section for production. Even if you have the database.yml file in .gitignore, Capistrano will bark if this file has no section for production. In my case, I had configured it to upload it to shared/config folder on deploy. Here is a sample database.yml config file for MySQL.

# Install the MYSQL driver
#   gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
#   gem 'mysql2'
#
# And be sure to use new-style password hashing:
#   http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: sample_sqlite3_development
  pool: 5
  username: root
  password:
  socket: /tmp/mysql.sock

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: sample_test
  pool: 5
  username: root
  password:
  socket: /tmp/mysql.sock

production:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: sample_production
  pool: 5
  username: root
  password:
  socket: /tmp/mysql.sock

To get the value for the socket, run:

mysqladmin variables | grep socket
| socket                                            | /var/run/mysqld/mysqld.sock  

on the server. Replace the socket value with the output, in my case /var/run/mysqld/mysqld.sock.


Related Articles