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

**URL:** <https://www.ruby-forum.com/t/ruby-mysql-incorrect-db-error-on-mac-osx-leopard/136016>\
**Category:** Rails\
**Created:** [April 28, 2008, 6:48am UTC](https://www.ruby-forum.com/t/ruby-mysql-incorrect-db-error-on-mac-osx-leopard/136016 "2008-04-28T06:48:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![thatguy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e5b9ba/32.png) [@thatguy](https://www.ruby-forum.com/u/thatguy)\
**Post date:** [April 28, 2008, 6:48am UTC](https://www.ruby-forum.com/t/ruby-mysql-incorrect-db-error-on-mac-osx-leopard/136016/1 "2008-04-28T06:48:46Z")

</div>

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: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. 🙂

---

<div class="post-metadata">

**Author:** ![thatguy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e5b9ba/32.png) [@thatguy](https://www.ruby-forum.com/u/thatguy)\
**Post date:** [April 28, 2008, 9:28am UTC](https://www.ruby-forum.com/t/ruby-mysql-incorrect-db-error-on-mac-osx-leopard/136016/2 "2008-04-28T09:28:33Z")

</div>

On Apr 28, 5:48 am, KC Booth [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

---

<div class="post-metadata">

**Author:** ![thatguy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e5b9ba/32.png) [@thatguy](https://www.ruby-forum.com/u/thatguy)\
**Post date:** [April 28, 2008, 9:32am UTC](https://www.ruby-forum.com/t/ruby-mysql-incorrect-db-error-on-mac-osx-leopard/136016/3 "2008-04-28T09:32:41Z")

</div>

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. \<  
removed\_email\_address@domain.invalid\> 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. 🙂
> > 
> > Posted viahttp://www.ruby-forum.com/.

–  
Jat is always RIGHT

---

<div class="post-metadata">

**Author:** ![thatguy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e5b9ba/32.png) [@thatguy](https://www.ruby-forum.com/u/thatguy)\
**Post date:** [April 28, 2008, 10:33am UTC](https://www.ruby-forum.com/t/ruby-mysql-incorrect-db-error-on-mac-osx-leopard/136016/4 "2008-04-28T10:33:03Z")

</div>

Frederick C. wrote:

> On Apr 28, 5:48ï¿½am, KC Booth [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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… 🙂 Thanks again.
