在 ruby 中连接到 mysql 会产生错误数量的参数错误 (4 of 0) - 如何调试?
我正在尝试从 Ruby 脚本连接到托管 MySQL 数据库。
require "rubygems"
require "mysql"
con = Mysql::new('host', 'user', 'pass', 'database')
运行此结果:
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
我的设置:
- 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)
我在连接时尝试使用这些变体:
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
请指出我朝着正确的方向前进。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有你的配置(我运行的是Linux)但是这篇文章似乎描述了您所看到的相同问题。
I don't have your configuration (I'm running Linux) but this article seems to describe the same problem you're seeing.