Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何让RubyonRails(Railsv4,Rubyv1.9.3)与MySQL一起工作_Mysql_Ruby_Ruby On Rails 4 - Fatal编程技术网

如何让RubyonRails(Railsv4,Rubyv1.9.3)与MySQL一起工作

如何让RubyonRails(Railsv4,Rubyv1.9.3)与MySQL一起工作,mysql,ruby,ruby-on-rails-4,Mysql,Ruby,Ruby On Rails 4,以下是我已经试图找到答案的地方: 和 我仍然不知道我做错了什么。正确配置database.yml后,我尝试创建项目,这是我得到的错误: “请更新路径以包含生成工具或下载DevKit 从“”开始,然后按照说明进行操作 在“ 安装mysql2(0.3.13)时出错,绑定程序无法继续。 在绑定之前,请确保gem安装mysql2-v“0.3.13”成功。” 为什么我找不到mysql2 v0.3.13? 操作系统:Windows7 Rails:4.0.0 Ruby:1.9.3 已安装DevKit 我遇到的

以下是我已经试图找到答案的地方: 和

我仍然不知道我做错了什么。正确配置database.yml后,我尝试创建项目,这是我得到的错误:

“请更新路径以包含生成工具或下载DevKit 从“”开始,然后按照说明进行操作 在“

安装mysql2(0.3.13)时出错,绑定程序无法继续。 在绑定之前,请确保
gem安装mysql2-v“0.3.13”
成功。”

为什么我找不到mysql2 v0.3.13?

操作系统:Windows7 Rails:4.0.0 Ruby:1.9.3 已安装DevKit

我遇到的错误
$bundle exec rails
找不到文件

$bundle
Bundler::GemfileNotFound

`$ gem install mysql2
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
        ERROR: Failed to build gem native extension.

        c:/Ruby193/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
*** 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:/Ruby193/bin/ruby
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib
        --without-mysql-lib=${mysql-dir}/lib
extconf.rb:37:in `<main>': undefined method `[]' for nil:NilClass (NoMethodError)


Gem files will remain installed in c:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.13 for inspection.`
`$gem安装mysql2
暂时增强包含DevKit的路径。。。
构建本机扩展。这可能需要一段时间。。。
错误:安装mysql2时出错:
错误:无法生成gem本机扩展。
c:/Ruby193/bin/ruby.exe extconf.rb
正在检查rb\u线程\u阻塞\u区域()。。。对
正在检查rb_wait_for_single_fd()。。。对
正在检查rb_hash_dup()。。。对
正在检查rb_intern3()。。。对
***extconf.rb失败***
由于某些原因无法创建Makefile,可能是缺少
必要的库和/或标题。查看mkmf.log文件了解更多信息
细节。您可能需要配置选项。
提供的配置选项:
--使用opt dir
--不带opt dir
--选择包含
--不带opt include=${opt dir}/include
--使用opt lib
--不带opt lib=${opt dir}/lib
--用make prog
--没有make prog
--srcdir=。
--库尔迪尔
--ruby=c:/Ruby193/bin/ruby
--使用mysql目录
--没有mysql目录
--使用mysql包括
--不带mysql include=${mysql dir}/include
--使用mysql库
--没有mysql-lib=${mysql-dir}/lib
extconf.rb:37:in`:nil:NilClass(NoMethodError)的未定义方法“[]”
Gem文件将保持安装在c:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.13中以供检查`

  • 关闭终端并再次打开
  • cd
    到正确的目录
  • 检查ruby版本(
    ruby-v
  • 检查rails版本
    bundle exec rails-v
  • 检查
    Gemfile
    是否存在
  • 运行
    bundle
  • 运行bundle exec rails

我安装了最新版本的MySQL,即5.x或6。我不知道该怎么弄清楚。Rails一直说找不到mysql2 gem。这就是我的gem文件中的内容:
#使用mysql作为活动记录gem“mysql2”的数据库。
。当我运行bundle时,这是输出:
Bundler::GemfileNotFound
关闭终端并再次打开
cd
到正确的目录。检查ruby版本(
ruby-v
)。检查rails版本
bundle exec rails-v
。检查
Gemfile
是否存在。运行
bundle
。运行
bundle exec rails
。如果这些检查中有任何一项失败,请编辑问题并准确地告诉我们哪里出了问题。复制粘贴您看到的实际错误。这些错误都不起作用,我将这些错误粘贴到编辑上。是否还有更多我需要发布的内容?请查看如何将文本格式化为代码。你粘贴的文本在其他地方是不可读的。结果是我不在正确的目录中,我必须在我在正确的目录中运行所有这些命令。
bundle exec rails
做什么?