Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.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
mysql2 ruby 2.3.1安装错误使用_Ruby_Ruby On Rails 3 - Fatal编程技术网

mysql2 ruby 2.3.1安装错误使用

mysql2 ruby 2.3.1安装错误使用,ruby,ruby-on-rails-3,Ruby,Ruby On Rails 3,我对Ruby不是很在行。当我尝试在本地运行我的应用程序时,它应该运行良好,但事实并非如此。当我启动服务器时 rails s 上面说 => Booting Unicorn => Rails 4.2.3 application starting in development on http://localhost:3000 => Run `rails server -h` for more startup options => Ctrl-C to shutdown serv

我对Ruby不是很在行。当我尝试在本地运行我的应用程序时,它应该运行良好,但事实并非如此。当我启动服务器时

rails s
上面说

=> Booting Unicorn
=> Rails 4.2.3 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
/home/lukni/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/connection_specification.rb:177:in `rescue in spec': Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError)
    from /home/lukni/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/connection_specification.rb:174:in `spec'
    from /home/lukni/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.3/lib/active_record/connection_handling.rb:50:in `establish_connection'
    from /home/lukni/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.3/lib/active_record/railtie.rb:120:in `block (2 levels) in <class:Railtie>'
    from /home/lukni/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.3/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
    from /home/lukni/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.3/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
    from /home/lukni/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.3/lib/active_support/lazy_load_hooks.rb:28:in `block in on_load'
=>引导独角兽
=>Rails 4.2.3应用程序在上开始开发http://localhost:3000
=>运行“rails服务器-h”以获得更多启动选项
=>Ctrl-C关闭服务器
退出
/home/lukni/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.3/lib/active\u record/connection\u adapters/connection\u specification.rb:177:在“rescue in spec”中:为数据库适配器指定了“mysql2”,但未加载gem。将'gem'mysql2'`添加到gem文件中(并确保其版本为ActiveRecord所要求的最低版本)。(Gem::LoadError)
来自/home/lukni/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.3/lib/active\u record/connection\u adapters/connection\u specification.rb:174:in'spec'
from/home/lukni/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.3/lib/active\u record/connection\u handling.rb:50:在“建立连接”中
from/home/lukni/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.3/lib/active_record/railtie.rb:120:in `块(两个级别)in'
from/home/lukni/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.3/lib/active\u support/lazy\u load\u hooks.rb:38:in'instance\u eval'
来自/home/lukni/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.3/lib/active\u-support/lazy\u-load\u-hooks.rb:38:in'execute\u-hook'
来自/home/lukni/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.3/lib/active\u-support/lazy\u-load\u-hooks.rb:28:in'block-in-on\u-load'
我正在使用Ruby 2.3.1


我需要在本地启动我的应用程序。

在rails项目文件夹中,您应该有一个名为
Gemfile
的文件

因此,只需在此文件中添加以下行:
gem'mysql2'
根据此错误消息:
addgem'mysql2'到您的gem文件中(并确保其版本为ActiveRecord所需的最低版本)

添加之后,请不要忘记通过
bundle install
命令更新gems


如果您在安装
mysql2
gem之后遇到一些问题,最好执行所有必需的步骤。

在rails项目文件夹中,您应该有一个名为
Gemfile
的文件

因此,只需在此文件中添加以下行:
gem'mysql2'
根据此错误消息:
addgem'mysql2'到您的gem文件中(并确保其版本为ActiveRecord所需的最低版本)

添加之后,请不要忘记通过
bundle install
命令更新gems

如果您在安装
mysql2
gem之后遇到一些问题,最好执行所有必需的步骤