我是Ruby,Rails和MySQL的新手。我正在尝试启动一个新项目并启动默认服务器,我得到下面列出的错误。我安装了以下内容:
错误如下:
$ rails s
/usr/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle: dlsym(0x251680, Init_mysql2): symbol not found - /usr/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle (LoadError)
from /usr/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2.rb:8
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `each'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `each'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler.rb:120:in `require'
from /Users/nelsonwittwer/Sites/simple_cms/config/application.rb:7
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27
from script/rails:6:in `require'
from script/rails:6
我不太确定从哪里开始,我会非常乐意为您提供帮助。谢谢。
答案 0 :(得分:0)
确保在ruby系统中安装了mysql2 gem。要检查它,请使用 gem list -d 。如果找不到mysql2 gem,在ubuntu中你必须在安装mysql2 gem之前安装以下库:
# sudo apt-get install libmysqlclient15-dev (for mysql-5.*)
# sudo apt-get install libmysql-ruby ruby-dev
之后,您可以使用 sudo gem install mysql2 进行安装,并确保database.yml中的适配器值为mysql2。另一个问题是未加载库,如果问题Library not loaded: libmysqlclient.16.dylib error when trying to run 'rails server' on OS X 10.6 with mysql2 gem
,您可以查看此链接答案 1 :(得分:0)
您需要在系统上安装mySQL gem。
现在,不要使用apt-get来安装它,因为apt-get经常有旧版本的ruby库。
另外,我强烈建议您在开始时使用SQLite。 而且,Bundler也非常有用(在railstutorial中描述)
基于ubuntu / debian的发行版(你真的想使用MySQL):
如果您使用的是ruby 1.8.x(请与ruby -v
联系):
sudo apt-get install libmysqlclient-dev
sudo apt-get install ruby-dev
sudo gem install mysql2
如果您使用的是ruby 1.9.x:
sudo apt-get install libmysqlclient-dev
sudo apt-get install ruby1.9.1-dev
sudo gem install mysql2