Ruby/mysql "incorrect db" error on Mac OSX (Leopard)

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.new
Mysql::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:inreal_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:ininitialize’
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:inmysql_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:inconnection_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:inretrieve_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:incolumns’
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:inattributes_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:ininitialize’
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. :slight_smile:

On Apr 28, 5:48 am, KC Booth [email protected] 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…)

Fred

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 C. <
[email protected]> wrote:

username: root

on? Seems like it’s not bound correctly, but I can’t for the life of me
bound to SQLite by default.

Thanks for any help you can give. :slight_smile:

Posted viahttp://www.ruby-forum.com/.


Jat is always RIGHT

Frederick C. wrote:

On Apr 28, 5:48�am, KC Booth [email protected] 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…)

Fred

Thanks, 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… :slight_smile: Thanks again.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs