Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are all possible keys for database.yml

I've just discovered that the reconnect: true configuration option is possible in the database.yml file. What other possible configuration options are there? Is there a complete reference for all options?

Known key examples:

default: &default
  adapter: mysql2
  encoding: utf8
  pool: 5
  username: foo
  password: bar
  reconnect: true
  socket: /var/sock/thing.sock

development:
  <<: *default
  database: app_development
like image 811
BookOfGreg Avatar asked Nov 09 '15 14:11

BookOfGreg


People also ask

What is database yml?

The database. yml is a file that is created with new rails applications in /config and defines the database configurations that your application will use in different environments.

What does << mean in yml?

The <<: inserts the content of that node. Allow me to quote the YAML spec here: Repeated nodes (objects) are first identified by an anchor (marked with the ampersand - “&”), and are then aliased (referenced with an asterisk - “*”) thereafter.

How do I find the database yml?

The database. yml is written to the /data/app_name/shared/config/ directory in the application and database instance (single server environment) or the application master instance (clustered environment).

Is Ruby on Rails a database?

Rails comes with built-in support for SQLite, which is a lightweight serverless database application. While a busy production environment may overload SQLite, it works well for development and testing. Rails defaults to using a SQLite database when creating a new project, but you can always change it later.


1 Answers

I don't think there is any place that just lists them but I checked the ActiveRecord's ConnectionAdapaters. Keep in mind that options change which database you use, but this was listed within the MySQL connection adapter.

List of Options for MySQL

:host - Defaults to "localhost".
:port - Defaults to 3306.
:socket - Defaults to "/tmp/mysql.sock".
:username - Defaults to "root"
:password - Defaults to nothing.
:database - The name of the database. No default, must be provided.
:encoding - (Optional) Sets the client encoding by executing "SET NAMES <encoding>" after connection.
:reconnect - Defaults to false (See MySQL documentation: http://dev.mysql.com/doc/refman/5.7/en/auto-reconnect.html).
:strict - Defaults to true. Enable STRICT_ALL_TABLES. (See MySQL documentation: http://dev.mysql.com/doc/refman/5.7/en/sql-mode.html)
:variables - (Optional) A hash session variables to send as SET @@SESSION.key = value on each database connection. Use the value +:default+ to set a variable to its DEFAULT value. (See MySQL documentation: http://dev.mysql.com/doc/refman/5.7/en/set-statement.html).
:sslca - Necessary to use MySQL with an SSL connection.
:sslkey - Necessary to use MySQL with an SSL connection.
:sslcert - Necessary to use MySQL with an SSL connection.
:sslcapath - Necessary to use MySQL with an SSL connection.
:sslcipher - Necessary to use MySQL with an SSL connection.

The github for Rails ActiveRecord adapters, https://github.com/rails/rails/tree/master/activerecord/lib/active_record/connection_adapters

edit: Adding what @pjrebsch commented below. You can also see MySQL options on the Mysql2 gem's Readme

like image 112
Jared Avatar answered Oct 17 '22 16:10

Jared