Last active
August 29, 2015 14:12
-
-
Save sathlan/e5af4d265cf7e34e585d to your computer and use it in GitHub Desktop.
OPT_PROTOCOL difficulty in mysql-gem.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/chef/embedded/bin/ruby | |
require 'mysql' | |
require 'optparse' | |
options = {:localhost => '127.0.0.1'} | |
OptionParser.new do |opts| | |
opts.on("-l", "Use localhost instead of 127.0.0.1") do |l| | |
options[:localhost] = 'localhost' | |
end | |
end.parse! | |
connection = ::Mysql.init | |
connection.options(::Mysql::OPT_PROTOCOL, 1) | |
connection.connect( | |
options[:localhost], | |
'test_user', | |
'user_passwd', | |
nil, | |
3306, | |
nil | |
) | |
connection.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment