什么是database.yml的所有可能键 [英] What are all possible keys for database.yml

查看:63
本文介绍了什么是database.yml的所有可能键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚发现 database.yml 文件中的 reconnect:true 配置选项是可能的。
还有哪些其他可能的配置选项?是否有所有选项的完整参考?

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?

已知关键示例:

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

development:
  <<: *default
  database: app_development


推荐答案

我认为没有任何地方可以列出它们,但是我检查了ActiveRecord的ConnectionAdapaters。请记住,选项会更改您使用的数据库,但这已在MySQL连接适配器中列出。

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.

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.

Rails ActiveRecord适配器的github, https://github.com/rails/rails/tree/master/activerecord/lib/active_record/connection_adapters

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

编辑:
添加下面@pjrebsch评论的内容。您还可以在 Mysql2 gem的自述文件

这篇关于什么是database.yml的所有可能键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆