2011-04-22 184 views
1

我對Ruby,Rails和MySQL是全新的。我正在嘗試啓動一個新項目並啓動默認服務器,並收到下面列出的錯誤。我已經安裝以下:Ruby on Rails服務器啓動問題

  • 紅寶石:紅寶石1.8.7(2008-08-11 PATCHLEVEL 72)[i686的-darwin9.8.0]
  • 導軌:導軌(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 

我不太確定該從哪裏出發,並會喜歡你可能有的任何幫助。謝謝。

回答

0

確保你的ruby系統中安裝了mysql2 gem。要檢查它使用寶石名單-d。如果沒有找到mysql2寶石,在Ubuntu中必須安裝以下庫安裝之前mysql2寶石:

# sudo apt-get install libmysqlclient15-dev (for mysql-5.*) 

# sudo apt-get install libmysql-ruby ruby-dev 

之後,你可以用安裝sudo的創業板安裝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

0

您需要在系統上安裝mySQL gem。

現在,不要使用apt-get來安裝它,因爲apt-get通常具有舊版本的ruby庫。

此外,我強烈建議您在開始時使用SQLite。 而且,捆紮機也很有幫助

(在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