views:

44

answers:

1

I'm trying to connect to a hosted MySQL database from my Ruby script.

require "rubygems"
require "mysql"

con = Mysql::new('host', 'user', 'pass', 'database')

Running this results in:

ArgumentError: wrong number of arguments (4 for 0)

method initialize  in untitled at line 4
method new         in untitled at line 4
at top level       in untitled at line 4

My setup:

  • Mac OS X Snow Leopard 10.6.4
  • Ruby 1.8.7
  • mysql (rubygem) 2.8.1
  • gem 1.3.7
  • MySQL 5.1.26 (hosted)

I've tried using these variants when connecting:

con = Mysql.new('host', 'user', 'pass', 'database')
# same as above

con = Mysql.real_connect('host', 'user', 'pass', 'database') 
# output => NoMethodError: undefined method ‘real_connect’ for Mysql:Class

Please point me in the right direction.

A: 

I don't have your configuration (I'm running Linux) but this article seems to describe the same problem you're seeing.

Richard Cook
Wauw thanks - running the gem install with the proper architecture arguments did the trick. :)
Michael
Btw: the is no reason to go un/re-install MySQL as the article suggests. Just the gem.
Michael