我对Ruby, Rails和MySQL完全陌生。我正试图启动一个新项目,并启动默认服务器,我得到下面列出的错误。我已经安装了以下文件:
- Ruby: Ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin9.8.0]
- Rails: Rails (3.0.7)MySql: mysql2 (0.2.7)
- RubyGems: 1.7.2
下面出现错误:
$ 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
我不太确定该从这里开始,希望你能提供任何帮助。谢谢你。
确保在你的ruby系统中安装了mysql2 gem。可以使用gem list -d查看。如果没有找到mysql2 gem,在安装mysql2 gem之前,必须先安装以下库:
# sudo apt-get install libmysqlclient15-dev (for mysql-5.*)
# sudo apt-get install libmysql-ruby ruby-dev
之后,你可以安装sudo gem install mysql2,并确保你的适配器值在数据库中。Yml是mysql2。另一个问题是库没有加载,你可以查看这个链接,如果问题库没有加载:libmysqlclient.16。运行'rails server'
你需要mySQL gem安装在你的系统上。
现在,不要使用apt-get来安装这个,因为apt-get通常有旧版本的ruby库。
另外,我强烈建议您在开始时使用SQLite。而且,Bundler也非常有用(在rails教程中有描述)
基于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