ruby on rails + xampp + mysql (windows 7)

2022-01-14 00:00:00 windows ruby-on-rails xampp mysql

我正在尝试在 Windows 7 上将 xampp 中包含的 mysql 包与 ruby​​ on rails 一起使用,但似乎无法让它们一起工作.

我有 rails 3.0.0 和 xampp 1.7.3

rails 可以在 xampp 中使用 sqlite,但是当尝试通过rails new project -d mysql; cd project; bundle install"使用 mysql 时

我得到以下信息:

<上一页>使用本机扩展安装 mysql2 (0.2.4) C:/xampp/Ruby192/lib/ruby/1.9.1/rubygems/installer.rb:483:in `rescue in block in build_extensions': 错误: 失败ed 来构建 gem 原生扩展.(Gem::Installer::ExtensionBuildError)C:/xampp/Ruby192/bin/ruby.exe extconf.rb检查 rb_thread_blocking_region()... *** extconf.rb 失败 ***由于某种原因无法创建 Makefile,可能缺少必要的库和/或头文件.查看 mkmf.log 文件了解更多信息细节.您可能需要配置选项.

我错过了什么吗?所有关于这个问题的帖子都告诉我使用 gem install mysql -- --with-mysql-config=PATH,但这似乎不适用于 Windows,因为无论如何我都会遇到同样的错误.

如果这是不可能的,那么现在使用 sqlite 是否有任何缺点,然后尝试将数据库迁移到 mysql(或另一个更强大的数据库)?

解决方案

gem install mysql --no-rdoc --no-ri -- '--with-mysql-lib="D:xamppmysqllib" --with-mysql-include="D:xamppmysqlinclude"'

我将此代码用于我的 mysql 解决方案,这是您可以将 mysql 用于 xampp 的正确方法.

I am trying to use the mysql package included in xampp with ruby on rails on windows 7, but cannot seem to get them to work together.

I have rails 3.0.0 and xampp 1.7.3

rails works with sqlite within xampp just fine, but when attempting to use mysql via "rails new project -d mysql; cd project; bundle install"

I get the following:

Installing mysql2 (0.2.4) with native extensions C:/xampp/Ruby192/lib/ruby/1.9.1
/rubygems/installer.rb:483:in `rescue in block in build_extensions': ERROR: Fail
ed to build gem native extension. (Gem::Installer::ExtensionBuildError)

C:/xampp/Ruby192/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.

Am I missing anything? All the posts about this issue tell me to use gem install mysql -- --with-mysql-config=PATH, but this does not seem to work with Windows, as I get the same error regardless.

And if it's just not possible, are there any drawbacks to using sqlite now, then trying to migrate the databse over to mysql (or another more robust database) later?

解决方案

gem install mysql --no-rdoc --no-ri -- '--with-mysql-lib="D:xamppmysqllib" --with-mysql-include="D:xamppmysqlinclude"'

I used this code for my solution of mysql this is the right way you can USE mysql for xampp.

相关文章