【问题标题】:Issues installing mysql or mysql2 gem安装 mysql 或 mysql2 gem 的问题
【发布时间】:2013-06-05 11:58:28
【问题描述】:

我安装了 ruby​​ 版本 2.0.0.0p195 (2013-05-14) [x64-mingw32] 以及 ruby​​ gem 版本 2.0.3。我最近也安装了 MySQL Community Server 5.6.12(32 位)安装程序。我正在尝试让 mysql 或 mysql2 gem 工作,然后安装服务器以了解有关 Ruby on Rails 的更多信息。

安装 mysql2 gem 时出现以下错误,任何人都可以指出正确的方向来安装 mysql2 gem,这样我就可以使用 ruby​​ on rails 和 mysql,然后最终使用 web serer。

构建原生扩展。这可能需要一段时间...

错误:安装 mysql2 时出错: 错误:无法构建 gem 原生扩展

> C:/Ruby200-x64/bin/ruby.exe extconf.rb checking for
> rb_thread_blocking_region()... *** extconf.rb failed *** Could not
> create Makefile due to some reason, probably lack of necessary
> libraries and/or headers.  Check the mkmf.log file for more details. 
> You may need configuration options.
> 
> Provided configuration options:   --with-opt-dir  --without-opt-dir
>   --with-opt-include  --without-opt-include=${opt-dir}/include
>   --with-opt-lib  --without-opt-lib=${opt-dir}/lib    --with-make-prog
>   --without-make-prog     --srcdir=.  --curdir
>   --ruby=C:/Ruby200-x64/bin/ruby
> C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:431:in `try_do': The compiler
> failed to generate an executable file. (RuntimeError) You have to
> install development tools first.  from
> C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:516:in `try_link0'  from
> C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:531:in `try_link'   from
> C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:717:in `try_func'   from
> C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:1001:in `block in have_func'
>   from C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:892:in `block in
> checking_for'     from C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:337:in
> `block (2 levels) in postpone'    from
> C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:307:in `open'   from
> C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:337:in `block in postpone'  from
> C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:307:in `open'   from
> C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:333:in `postpone'   from
> C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:891:in `checking_for'   from
> C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:1000:in `have_func'     from
> extconf.rb:9:in `<main>'

【问题讨论】:

  • 我在这个问题上遇到了很多麻烦。如果您只是在学习,我实际上建议您只使用 sqlite3,特别是如果您使用的是 Windows 64 位机器。很容易在 MySql 上耽搁好几天。如果您想尝试,这里有一个资源:gamecreatures.com/blog/2011/08/31/…
  • sqllite3会和wamp服务器冲突吗?我正在为另一个项目运行。除非 wamp 和 RoR 可以集成在一起。
  • 我对 WAMP 不是很熟悉,但只要您使用不同的 shcema 名称,您应该不会有问题。另一个选择是 postgresql,我也发现它比 MySQL 更容易。

标签: ruby-on-rails gem mysql2


【解决方案1】:

我发现(对我而言)答案是使用 rails 安装程序并卸载我的旧 ruby​​ 信息。 Rails 安装程序包括 ruby​​、rails 和 sqllite3。同样,然后我安装了运行 localhost:3000 的 WEBrick。它允许我拥有 WAMP 和 Ruby/WEBrick。这并不理想,因为一切都不是在一个区域上运行的,但对于我需要它的学习和我想使用 HTML5 和/或 Rails(媒体应用程序)开发的副项目来说非常有用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-21
    • 1970-01-01
    • 2011-08-02
    • 2012-12-21
    • 2011-08-16
    相关资源
    最近更新 更多