What are all possible keys for database.yml

我是研究僧i 提交于 2019-12-09 05:22:13

问题


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

回答1:


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



来源:https://stackoverflow.com/questions/33611849/what-are-all-possible-keys-for-database-yml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!