简体   繁体   中英

use .my.cnf for ruby mysql connection

In a ruby script (not rails) Iam using mysql. Because my mysql are available in a .my.cnf file, I can use mysql on the terminal without password. But that does not work in a ruby script, how can I achieve that?

If you are using mysql2 , you may need to read the .my.conf manually, as show in the doc

Reading a MySQL config file

You may read configuration options from a MySQL configuration file by passing the :default_file and :default_group parameters. For example:

Mysql2::Client.new(:default_file => '/user/.my.cnf', :default_group => 'client')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM