简体   繁体   English

需要Ruby Gem LoadError mysql2 / mysql2

[英]Ruby Gem LoadError mysql2/mysql2 required

Im trying to setup my rails server on OSX 10.8 but I can't get my rails server to run. 我试图在OSX 10.8上设置我的rails服务器,但我无法让我的rails服务器运行。
- Currently Im using a Zend Server with mysql 5.1. - 目前我正在使用带有mysql 5.1的Zend Server。
- I also have istalled brew and brew mysql . - 我还有brewbrew mysql
- And I used: - 我用过:
gem install mysql2 -- --srcdir=/usr/local/mysql/include --with-opt-include=/usr/local/mysql/include
the server worked already but now, I always get this loadError below. 服务器已经工作但是现在,我总是在下面得到这个loadError。

This is what my Gemfile says: 这是我的Gemfile所说的:

ralphs-macbook-pro:admin-mockup zero$ bundle install
Using rake (10.0.2) 
Using i18n (0.6.1) 
Using multi_json (1.3.7) 
Using activesupport (3.2.7) 
Using builder (3.0.4) 
Using activemodel (3.2.7) 
Using erubis (2.7.0) 
Using journey (1.0.4) 
Using rack (1.4.1) 
Using rack-cache (1.2) 
Using rack-test (0.6.2) 
Using hike (1.2.1) 
Using tilt (1.3.3) 
Using sprockets (2.1.3) 
Using actionpack (3.2.7) 
Using mime-types (1.19) 
Using polyglot (0.3.3) 
Using treetop (1.4.12) 
Using mail (2.4.4) 
Using actionmailer (3.2.7) 
Using arel (3.0.2) 
Using tzinfo (0.3.35) 
Using activerecord (3.2.7) 
Using activeresource (3.2.7) 
Using annotate (2.5.0) 
Using coffee-script-source (1.4.0) 
Using execjs (1.4.0) 
Using coffee-script (2.2.0) 
Using rack-ssl (1.3.2) 
Using json (1.7.5) 
Using rdoc (3.12) 
Using thor (0.16.0) 
Using railties (3.2.7) 
Using coffee-rails (3.2.2) 
Using columnize (0.3.6) 
Using debugger-ruby_core_source (1.1.5) 
Using debugger-linecache (1.1.2) 
Using debugger (1.2.2) 
Using formtastic (2.2.1) 
Using haml (3.1.7) 
Using haml-rails (0.3.5) 
Using hirb (0.7.0) 
Using hpricot (0.8.6) 
Using jquery-rails (2.1.4) 
Using kgio (2.7.4) 
Using mysql2 (0.3.11) 
Using php_serialize (1.2) 
Using polyamorous (0.5.0) 
Using rabl (0.7.8) 
Using railroady (1.1.0) 
Using bundler (1.2.3) 
Using rails (3.2.7) 
Using raindrops (0.10.0) 
Using randumb (0.3.0) 
Using sass (3.2.3) 
Using sass-rails (3.2.5) 
Using squeel (1.0.13) 
Using uglifier (1.3.0) 
Using unicorn (4.4.0) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled
gem is installed.

And after starting rails s 并且在启动rails s之后

/Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/mysql2-0.3.11/lib/mysql2.rb:9:in `require': cannot load such file -- mysql2/mysql2 (LoadError)
from /Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/mysql2-0.3.11/lib/mysql2.rb:9:in `<top (required)>'
from /Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `require'
from /Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `each'
from /Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `block in require'
from /Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `each'
from /Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `require'
from /Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.3/lib/bundler.rb:128:in `require'
from /Users/zero/GitHub/admin-mockup/config/application.rb:7:in `<top (required)>'
from /Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.7/lib/rails/commands.rb:53:in `require'
from /Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.7/lib/rails/commands.rb:53:in `block in <top (required)>'
from /Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.7/lib/rails/commands.rb:50:in `tap'
from /Users/zero/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.7/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

Thx for any help! 感谢任何帮助!

after that I changed my database.yml as follows: 之后我改变了我的database.yml,如下所示:

development:
  adapter: mysql2
  socket: /usr/local/zend/mysql/tmp/mysql.sock
  #host: 127.0.0.1

so that I used my local zend MySQL socket. 所以我使用了我的本地zend MySQL套接字。 In my case the ""Can't connect to MySQL server on '127.0.0.1' (61) (Mysql2::Error)" was gone. 在我的情况下,“无法连接到'127.0.0.1'(61)(Mysql2 ::错误)上的MySQL服务器”已经不见了。

Thx @dinnouti for the usefull links above. 感谢@dinnouti上面有用的链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM