Today I discovered an interesting behavior of the mysql database adapter when connecting to a tunneled localhost port for MySQL from OSX. i started a tunnel using the usual ssh command line options: ssh -p 22 -L 3307:localhost:3306 user-3I8OyKyBCfAtS7CogBbXo5owlv4uC7bZ@public.gmane.org then in database.yml THIS WORKS development: adapter: mysql encoding: utf8 database: dev_data username: dev_admin password: password host: 127.0.0.1 port: 3307 THIS FAILS development: adapter: mysql encoding: utf8 database: dev_data username: dev_admin password: password host: localhost port: 3307 It seems that the adapter will automatically force a mysql.sock to be used when host: is set to localhost. Switching host: to the actual IP seems to allow the port option to go into effect. Just wanted to post this so others may find the solution I did, more quickly. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 2007-10-27 08:20:15 -0700, Jb Smith <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> said:> THIS WORKS > host: 127.0.0.1 > > THIS FAILS > host: localhost > > It seems that the adapter will automatically force a mysql.sock to be > used when host: is set to localhost.Yes, I''ve noticed this myself; it''s not particular to Rails. I have to do this when using CocoaMySQL to connect to my remote database via ssh tunnel. I sure would like to know why it works this way too... Is "localhost" just a magic keyword for using the socket? --Andrew Vit --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you! That is exactly how to get ruby mysql to run on a port instead of on the unix socket. Odd that it would be necessary. Note also that for mysql command line to work with ''just a socket'' and not automatically use the port, you need to run mysql -uwhatever -p --protocol=tcp --port=whatever # or it won''t use the port, only uses the local socket (at least on os x). Thank you. -Roger> then in database.yml > THIS WORKS > > development: > adapter: mysql > encoding: utf8 > database: dev_data > username: dev_admin > password: password > host: 127.0.0.1 > port: 3307-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---