I'm assuming you've got this installed:
http://ruby-dbi.sourceforge.net/

What did I do to get this to work?

start> run> odbcad32

click system dsn, choose add.

Look for MySQL at the bottom.. if it's not there, download and install it:
http://dev.mysql.com/get/Downloads/MyODBC3/MyODBC-3.51.11-2-win.msi/from/pick

Afer installing it, click add again within the odbcad32 window, and
select the mysql driver..

put in the hostname and db details.. give the connector a name which
you will use with the connection shizza...  test the connection then
close..

Create the ruby script to test it..
This example pretty much worked for me:

require 'dbi'

# connect to a datbase
dbh = DBI.connect('DBI:Mysql:test', 'testuser', 'testpwd')

puts "selecting..."
sth=dbh.prepare('select * from simple01')
sth.execute

while row=sth.fetch do
 p row
end



On 9/16/05, Sean Armstrong <phinsxiii / gmail.com> wrote:
> I currently have the MySQL binary for Windows installed. I have ruby under
> both cygwin and windows installed. I can not get the DBI module for either
> ruby version to connect to my mysql database. Here is the code:
> 
> require 'dbi' # so far so good
> 
> dbh = DBI.connect('DBI:Mysql:test', 'testuser', 'testpwd') # here's
> where it crashes
>  from /usr/lib/ruby/site_ruby/1.8/dbi/dbi.rb:499:in `load_driver'
>  from /usr/lib/ruby/site_ruby/1.8/dbi/dbi.rb:401:in `_get_full_driver'
>  from /usr/lib/ruby/site_ruby/1.8/dbi/dbi.rb:381:in `connect'
>  from (irb):5
> 
> I thought that maybe I had to declare the host so:
> 
> dbh = DBI.connect('DBI:Mysql:test:.', 'testuser', 'testpwd') # here's
> where it crashes
>  from /usr/lib/ruby/site_ruby/1.8/dbi/dbi.rb:499:in `load_driver'
>  from /usr/lib/ruby/site_ruby/1.8/dbi/dbi.rb:401:in `_get_full_driver'
>  from /usr/lib/ruby/site_ruby/1.8/dbi/dbi.rb:381:in `connect'
>  from (irb):5
> 
> I thought maybe there was something wrong with the database but the
> following connects just fine in the terminal:
> 
> mysql -u testuser -p -h . test
> 
> I can not seem to get the DBI to work with Windows, apparently the ruby
> modules are only good with Unix and not Windows. Please do not say try
> mysql-ruby. I can not even get that to compile. I've tried compiling Mysql
> source for the libs but it still refuses to find the mysql libs no matter
> wher I point extcong.rb. So I tried going back to DBI. That is where I stand
> now. Certainly someone out there has been able to get this module to work
> properly with the MySQL binary install and WinXP?
> 
> Thanks:)
> 
> SA
> 
> --
> "I can do everything on my Mac that I could do on a PC."
> -- Me
> 
>