在 ruby​​ 中连接到 mysql 会产生错误数量的参数错误 (4 of 0) - 如何调试?

发布于 2024-09-24 12:06:40 字数 819 浏览 1 评论 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尐偏执 2024-10-01 12:06:40

我没有你的配置(我运行的是Linux)但是这篇文章似乎描述了您所看到的相同问题。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文