我刚刚发现在
database.yml文件中可以使用reconnect:true配置选项.
还有哪些其他可能的配置选项?所有选项都有完整的参考吗?
还有哪些其他可能的配置选项?所有选项都有完整的参考吗?
已知的关键示例:
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连接适配器中列出的.
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
编辑:
添加@pjrebsch在下面评论的内容.您还可以在Mysql2 gem’s Readme上看到MysqL选项
原文地址:https://www.jb51.cc/ruby/270364.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。