I'm trying to get my first ruby box set up.  I'm so far unable to
connect to the mysql database with mysql-ruby.

I'm on an Intel Mac, running macosx tiger 10.4.8.  At first, I couldn't
even compile the plugin, there is some bug in the software.  It gave an
error like

mysql.c: In function 'Init_mysql':
mysql.c:2015: error: 'ulong' undeclared (first use in this function)

After googling around, I found that this error is known, and can be
fixed by simply declaring that variable in mysql.c.  See
http://www.maxdunn.com/typo/articles/2006/12/12/installing-mysql-gem-on-mac-os-x-10-4
or
http://typo.pburkholder.com/articles/tag/macosx
or
http://www.planetrubyonrails.org/show/feed/11
for details.

After declaring that variable, the software compiled successfully, but
was unable to connect to the database.  When I run the test file with

$ /usr/local/bin/ruby test.rb localhost root password

I get 180 errors all looking something like

179) Error:
test_sqlstate(TC_MysqlStmt2):
Mysql::Error: Access denied for user 'lethe'@'localhost' (using
password: NO)
    test.rb:441:in `new'
    test.rb:441:in `setup'

I notice that it's not trying to connect with the username and password
I specified on the command line.  "lethe" is my account login, whereas
my sql login is "root".  And it's not specifying a password.  Perhaps
listing host, user, and password on the command line is not the right
way to specify for test.rb?

I can connect manually to the database just fine, and here is my user
table:
mysql> select Host,User,Password from mysql.user;
+-----------+-------+-------------------------------------------+
| Host      | User  | Password                                  |
+-----------+-------+-------------------------------------------+
| localhost | root | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
| avernus   | root | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
| avernus   |       | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
| localhost |       | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
+-----------+-------+-------------------------------------------+
4 rows in set (0.00 sec)

that password is the encrypted version of the word "password".

Forging ahead blindly, I figure that if these tests are failing because
they can't login, they're not specifying a password, it might help if I
*remove* the password.  So after removing the passwords from the
database and flushing privileges, I can connect manually to the dbase
without a password, like
$ mysql -u root
or even just
$ mysql

Now, when I run the mysql-ruby test, it works!

$ /usr/local/bin/ruby test.rb localhost root password
Loaded suite test
Started
....................................................................FF...........................................
Finished in 0.271991 seconds.

  1) Failure:
test_fetch_double(TC_MysqlStmt2) [test.rb:920]:
<-1.79769313486232e+308> and
<-1.79769313486232e+308> expected to be within
<2.22044604925031e-16> of each other.

  2) Failure:
test_fetch_double_unsigned(TC_MysqlStmt2) [test.rb:937]:
<1.79769313486232e+308> and
<1.79769313486232e+308> expected to be within
<2.22044604925031e-16> of each other.

113 tests, 376 assertions, 2 failures, 0 errors

Only two of the several hundred tests fail, and those two probably
don't mean anything, I figure.

Alas, I still cannot connect to the database from my mod_ruby script.
My script contains essentially:

<%
require 'mysql'
dbh = Mysql.real_connect("localhost", "root", "", "test")
puts "Server version: " + dbh.get_server_info
%>

The browser shows me the HTTP 500 error page, and my apache log shows
me:

[Mon Jan 01 23:46:01 2007] [error] mod_ruby:
/usr/local/apache2/htdocs/db.rhtml:13:in `real_connect': Can't connect
to MySQL server on 'localhost' (49) (Mysql::Error)

I suspect that the mysql-ruby plugin is not sending the correct
host/user/password as specified, but I'm really not sure, nor can I
figure out a way to debug this further.  Any help you can offer me
would be greatly appreciated.

Thanks,
lethe