# Db:migrate and Mysql error

**URL:** <https://www.ruby-forum.com/t/db-migrate-and-mysql-error/159847>\
**Category:** Rails\
**Created:** [February 9, 2009, 11:48am UTC](https://www.ruby-forum.com/t/db-migrate-and-mysql-error/159847 "2009-02-09T11:48:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 9, 2009, 11:48am UTC](https://www.ruby-forum.com/t/db-migrate-and-mysql-error/159847/1 "2009-02-09T11:48:39Z")

</div>

Hi,  
Am getting the error “undefined method `each’ for #Mysql:0x483f2d0”  
when I try to run a “rake db:migrate” on a very simple example for a  
Mysql database. This follows a very basic setup procedure that works  
with sqlite3, but fails when I try to use Mysql (note that I have  
verified that the db on mysql is created and accessible to rails)

> rails photos  
> cd photos  
> ruby script/generate scaffold photo filename:string thumbnail:string description:string  
> rake db:migrate  
> at this point I get an error (see below). Note that the  
> schema\_migrations table is created and if I run the rake command then  
> the table photos is also created (but I get a command out of sequence  
> error from rails).

I have read relevant posts regarding versions of mysql and  
libmysql.dll which I have taken action on.  
I would appreciate any clues as it is driving me nuts %).

I am using:  
MS Windows XP Home Ediition Version 2002 SP3  
ruby ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32]  
rails 2.2.2  
mysql gem 2.7.3  
Mysql 5.1.31-community

Cheers  
Barry

The trace is as follows:  
C:\rails\photos\>C:\rails\photos\>rake db:migrate --trace  
(in C:/rails/photos)  
\*\* Invoke db:migrate (first\_time)  
\*\* Invoke environment (first\_time)  
\*\* Execute environment  
\*\* Execute db:migrate  
rake aborted!  
undefined method `each' for #<Mysql:0x483f2d0> C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ connection_adapters/mysql_adapter.rb:414:in`tables’  
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active\_record/  
connection\_adapters/abstract/schema\_statements.rb:330:in  
`initialize_schema_migrations_table' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ migration.rb:430:in`initialize’  
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active\_record/  
migration.rb:394:in `new' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ migration.rb:394:in`up’  
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active\_record/  
migration.rb:377:in `migrate' C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/tasks/databases.rake: 111 C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in`call’  
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `execute' C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in`each’  
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `execute' C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:578:in`invoke\_with\_call\_chain’  
C:/Ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize' C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in`invoke\_with\_call\_chain’  
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:564:in `invoke' C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2019:in`invoke\_task’  
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in  
`top_level' C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in`each’  
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in  
`top_level' C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in`standard\_exception\_handling’  
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1991:in  
`top_level' C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1970:in`run’  
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in  
`standard_exception_handling' C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1967:in`run’  
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/bin/rake:31  
C:/Ruby/bin/rake:19:in `load’  
C:/Ruby/bin/rake:19

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 9, 2009, 11:51am UTC](https://www.ruby-forum.com/t/db-migrate-and-mysql-error/159847/2 "2009-02-09T11:51:00Z")

</div>

On Feb 9, 10:11 am, “removed\_email\_address@domain.invalid” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> 

I recall vaguely seeing messages about this previously with the end  
result being that mysql 5.1.x was the problem.

Fred

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 11, 2009, 12:22pm UTC](https://www.ruby-forum.com/t/db-migrate-and-mysql-error/159847/3 "2009-02-11T12:22:31Z")

</div>

Discovered the solution elsewhere and thanks to fred who provide  
enough of an addition clue to hunt down other oblique references to  
the problem:

The problem is that libmysql.dll shipped with Mysql 5.1 doesn’t play  
well with ruby 2.2…

The solution is to download the libmysql.dll from:

[http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/libmySQL.dll](http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/libmySQL.dll)

and save this in your ruby bin directory

see also:  
[http://forums.aptana.com/viewtopic.php?f=20&t=7563&p=27407&hilit=libmysql.dll#p27407](http://forums.aptana.com/viewtopic.php?f=20&t=7563&p=27407&hilit=libmysql.dll#p27407)

On Feb 9, 9:50 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
