Skip to content

Instantly share code, notes, and snippets.

@datt
Last active Apr 7, 2021
Embed
What would you like to do?
Rails Database yml examples for postgres sqlite and mysql
# Install the MySQL gem:
# gem install mysql2
default: &default
adapter: mysql2
encoding: utf8mb4
reconnect: false
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password:
socket: /tmp/mysql.sock
development:
<<: *default
database: app_name_development
test:
<<: *default
database: app_name_test
staging:
<<: *default
database: app_name_staging
production:
<<: *default
database: app_name_production
# Install the pg gem:
# gem install pg
default: &default
adapter: postgresql
encoding: unicode
host: localhost
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: postgres
password:
development:
<<: *default
database: app_name_development
test:
<<: *default
database: app_name_test
staging:
<<: *default
database: app_name_staging
production:
<<: *default
database: app_name_production
# SQLite version 3.x
# gem install sqlite3
default: &default
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
# 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:
<<: *default
database: db/test.sqlite3
staging:
<<: *default
database: db/staging.sqlite3
production:
<<: *default
database: db/production.sqlite3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment