开发者

Connecting to mysql in ruby produces wrong number of arguments error (4 of 0) - how to debug?

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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜