我想在我的mac osx 10.9.3上运行rails应用程序并出现以下错误:
/Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/mysql2-0.3.16/lib/mysql2.rb:8:in `require': Incorrect MySQL client library version! This gem was compiled for 5.5.23 but the client library is 5.6.19. (RuntimeError)
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/mysql2-0.3.16/lib/mysql2.rb:8:in `<top (required)>'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.3/lib/bundler/runtime.rb:76:in `require'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.3/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.3/lib/bundler/runtime.rb:72:in `each'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.3/lib/bundler/runtime.rb:72:in `block in require'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.3/lib/bundler/runtime.rb:61:in `each'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.3/lib/bundler/runtime.rb:61:in `require'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.3/lib/bundler.rb:132:in `require'
from /Users/home/workSpace/RubyOnRails/simple_cms/config/application.rb:7:in `<top (required)>'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:79:in `require'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:79:in `block in server'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:76:in `tap'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:76:in `server'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:8:in `require'
from bin/rails:8:in `<main>'
我用hombrew安装了mysql,它运行得很好。我也使用rbenv。
gem 'rails', '4.1.1'
gem 'mysql2'
这是我的databas.yml文件
development:
adapter: mysql2
encoding: utf8
database: simple_cms_development
pool: 5
username: root
password: somepassword
socket: /tmp/mysql.sock
test:
adapter: mysql2
encoding: utf8
database: simple_cms_test
pool: 5
username: root
password: somepassword
socket: /tmp/mysql.sock
production:
adapter: mysql2
encoding: utf8
database: simple_cms_production
pool: 5
username: root
password: somepassword
socket: /tmp/mysql.sock
我该如何解决?
答案 0 :(得分:0)
<强>接头强>
我打算建议使用mysql C-connector
(评论中的推荐答案确认了这一点)
我们已经写了tutorial关于如何执行此操作(针对典型的unable to build native extensions
错误),但同样的想法
-
<强> C-连接器强>
基本上,您的gem
只需要接口与您的系统;它不需要做任何事情购买发送查询&amp;处理对数据库的响应
这意味着如果你的mysql版本的兼容性有问题,你最好安装&amp;使用单独一批header
个文件(对于您的gem
):
执行此操作的方法是download & install the
mysql c-connector
files - 重要 - 获取32位版本(您可以使用 安装程序或解压缩文件)安装完成后,您应该使用以下命令安装gem:
gem install mysql2 --platform=ruby -- ‘--with-mysql-dir="YOUR_MYSQL_DIR”’
这个 应该为你安装gem,这将允许你与MYSQL服务器接口