Hey, folks - I''ve got a newbie question that I couldn''t find anywhere in the forum archives. Just installed RoR on Mac OSX (Leopard), and wanted to connect it to MySQL instead of SQLite. I downloaded the gem: sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql I create my databases in MySQL (rubytryout_development, rubytryout_test, and rubytryout_production), but when I load up Ruby and try to create a class, here''s what happens:>> class Book < ActiveRecord::Base; end=> nil>> book = Book.newMysql::Error: #42000Incorrect database name ''db/rubytryout_development'' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/vendor/mysql.rb:523:in `read'' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/vendor/mysql.rb:153:in `real_connect'' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/connection_adapters/mysql_adapter.rb:389:in `connect'' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/connection_adapters/mysql_adapter.rb:152:in `initialize'' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/connection_adapters/mysql_adapter.rb:82:in `new'' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/connection_adapters/mysql_adapter.rb:82:in `mysql_connection'' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/connection_adapters/abstract/connection_specification.rb:262:in `send'' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/connection_adapters/abstract/connection_specification.rb:262:in `connection_without_query_cache='' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/query_cache.rb:54:in `connection='' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/connection_adapters/abstract/connection_specification.rb:230:in `retrieve_connection'' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/connection_adapters/abstract/connection_specification.rb:78:in `connection'' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/base.rb:763:in `columns'' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/base.rb:2063:in `attributes_from_column_definition_without_lock'' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/locking/optimistic.rb:45:in `attributes_from_column_definition'' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/base.rb:1505:in `initialize_without_callbacks'' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/callbacks.rb:225:in `initialize'' from (irb):2:in `new'' I can''t make sense of this. I''ve updated the database.yml file to: development: adapter: mysql encoding: utf8 database: db/rubytryout_development username: root password: socket: /tmp/mysql.sock test: adapter: mysql encoding: utf8 database: db/rubytryout_test username: root password: socket: /tmp/mysql.sock production: adapter: mysql encoding: utf8 database: db/rubytryout_production username: root password: socket: /tmp/mysql.sock I''ve installed the MySQL gem to the appropriate mysql directory, and I''ve verified that the databases exist...any ideas what could be going on? Seems like it''s not bound correctly, but I can''t for the life of me figure it out. What am I missing? I imagine there''s an easy fix, so apologies in advance if this is a ''dumb newbie'' question. I''m used to running and querying MySQL, but not installing it or messing around in Unix, so there''s a steep learning curve here. Especially now that Ruby comes standard on OSX, but is now bound to SQLite by default. Thanks for any help you can give. :-) -- 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Apr-28 07:28 UTC
Re: ruby/mysql "incorrect db" error on Mac OSX (Leopard)
On Apr 28, 5:48 am, KC Booth <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I can''t make sense of this. I''ve updated the database.yml file to: > > development: > adapter: mysql > encoding: utf8 > database: db/rubytryout_development > username: root > password: > socket: /tmp/mysql.sock > > test: > adapter: mysql > encoding: utf8 > database: db/rubytryout_test > username: root > password: > socket: /tmp/mysql.sock > > production: > adapter: mysql > encoding: utf8 > database: db/rubytryout_production > username: root > password: > socket: /tmp/mysql.sock > > I''ve installed the MySQL gem to the appropriate mysql directory, and > I''ve verified that the databases exist...any ideas what could be going > on? Seems like it''s not bound correctly, but I can''t for the life of me > figure it out. What am I missing?None of those database files should start with db/ (ie they should just be rubytryout_development etc...) Fred> > I imagine there''s an easy fix, so apologies in advance if this is a > ''dumb newbie'' question. I''m used to running and querying MySQL, but not > installing it or messing around in Unix, so there''s a steep learning > curve here. Especially now that Ruby comes standard on OSX, but is now > bound to SQLite by default. > > Thanks for any help you can give. :-) > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
vikas nandal
2008-Apr-28 07:31 UTC
Re: ruby/mysql "incorrect db" error on Mac OSX (Leopard)
I think you don''t need to give db/rubytryout_development. Instead of it you have to use rubytryout_development. It will work. On Mon, Apr 28, 2008 at 12:58 PM, Frederick Cheung < frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > On Apr 28, 5:48 am, KC Booth <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > I can''t make sense of this. I''ve updated the database.yml file to: > > > > development: > > adapter: mysql > > encoding: utf8 > > database: db/rubytryout_development > > username: root > > password: > > socket: /tmp/mysql.sock > > > > test: > > adapter: mysql > > encoding: utf8 > > database: db/rubytryout_test > > username: root > > password: > > socket: /tmp/mysql.sock > > > > production: > > adapter: mysql > > encoding: utf8 > > database: db/rubytryout_production > > username: root > > password: > > socket: /tmp/mysql.sock > > > > I''ve installed the MySQL gem to the appropriate mysql directory, and > > I''ve verified that the databases exist...any ideas what could be going > > on? Seems like it''s not bound correctly, but I can''t for the life of me > > figure it out. What am I missing? > None of those database files should start with db/ (ie they should > just be rubytryout_development etc...) > > Fred > > > > I imagine there''s an easy fix, so apologies in advance if this is a > > ''dumb newbie'' question. I''m used to running and querying MySQL, but not > > installing it or messing around in Unix, so there''s a steep learning > > curve here. Especially now that Ruby comes standard on OSX, but is now > > bound to SQLite by default. > > > > Thanks for any help you can give. :-) > > -- > > Posted viahttp://www.ruby-forum.com/. > > >-- Jat is always RIGHT --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On Apr 28, 5:48�am, KC Booth <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> test: >> � database: db/rubytryout_production >> � username: root >> � password: >> � socket: /tmp/mysql.sock >> >> I''ve installed the MySQL gem to the appropriate mysql directory, and >> I''ve verified that the databases exist...any ideas what could be going >> on? Seems like it''s not bound correctly, but I can''t for the life of me >> figure it out. What am I missing? > None of those database files should start with db/ (ie they should > just be rubytryout_development etc...) > > FredThanks, Fred (& Vikas) - that did it! Hallelujah. For some reason I had it in my head that Ruby actually wrote databases to the /db folder...like I said, I know nothing about MySQL config, and how it interacts with Unix. Now I''m off to find a good book on the subject, so I can quit pestering you all with simple questions... :) Thanks again. -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---