First, either:
gem install mysql --remote
(pick the Win32 version when/if given a choice.)
..or install it by hand from here (needs a compiler):
http://www.tmtm.org/en/mysql/ruby/
Once you have that, try running this code.
require 'rubygems'
require 'mysql'
HOST = 'localhost'
USER = 'root'
PASSWORD = nil
DATABASE = 'put_your_database_name_here'
connection = Mysql.real_connect(HOST, USER, PASSWORD, DATABASE)
connection.query "show tables" do |result_set|
result_set.each {|row| puts row}
end
This is painfully low-level, and not really how anyone should be
writing database code in Ruby. However, if it prints out a list of the
tables in your database, you know it's working.
In real life, you should use something like DBI, ActiveRecord, or Og.
That way you aren't dealing with the nitty-gritty connection details
all the time, and it is easier to switch databases later.
DBI is also fairly low-level, but at least it is the same across all
database platforms.