Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法使用 mysql gem 连接到 MySQL 服务器而不传递用户名/密码组合,而是从 .my.cnf 文件加载它?
加载它们的最简单方法是使用inifilegem。
inifile
require 'inifile' client_options_hash = IniFile.new('~/.my.cnf')['client']
然后您可以使用 from 的值client_options_hash来设置您的连接。
client_options_hash