2013-01-04 34 views
2

所以。我試圖建立一個Rails應用程序,我試圖在Windows 7這裏這樣做的我做了什麼:Windows上的Mysql2和Rails

  1. 使用安裝了Ruby 1.9.3 ruby​​installer
  2. gem update
  3. gem install rails
  4. gem update
  5. rails new
  6. 修改了的Gemfile,與mysql2
  7. 替換
  8. 修改database.yml的正確
  9. bundle install
  10. gem update
  11. 新增的對MySQL,是我路上
  12. 增加了一個硬連接在紅寶石賓

一切工作的的libmysql C連接到目前爲止,除了當我做rake db:create:all,導致:

rake aborted! 
126: The specified module could not be found. - C:/Ruby193/lib/ruby/gems/1.9.1 
/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/1.9/mysql2.so 
C:/Users/username/Documents/workspace/appname/config/application.rb:7:in `<top (
required)>' 
C:/Users/username/Documents/workspace/appname/Rakefile:5:in `<top (required)>' 
(See full trace by running task with --trace) 

wtf?

UPDATE:

完整跟蹤,通過要求:

rake aborted! 
126: The specified module could not be found. - C:/Ruby193/lib/ruby/gems/1.9.1 
/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/1.9/mysql2.so 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2. 
rb:2:in `require' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2. 
rb:2:in `<top (required)>' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2.rb:9:in 
`require' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2.rb:9:in 
`<top (required)>' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in ` 
require' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in ` 
block (2 levels) in require' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in ` 
each' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in ` 
block in require' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in ` 
each' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in ` 
require' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler.rb:128:in `require 
' 
C:/Users/mschultz/Documents/workspace/recruit/config/application.rb:7:in `<top (
required)>' 
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' 
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' 
C:/Users/mschultz/Documents/workspace/recruit/Rakefile:5:in `<top (required)>' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_module.rb:25:in `l 
oad' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_module.rb:25:in `l 
oad_rakefile' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:583:in ` 
raw_load_rakefile' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:89:in `b 
lock in load_rakefile' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:160:in ` 
standard_exception_handling' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:88:in `l 
oad_rakefile' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:72:in `b 
lock in run' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:160:in ` 
standard_exception_handling' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:70:in `r 
un' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/bin/rake:33:in `<top (required)> 
' 
C:/Ruby193/bin/rake:23:in `load' 
C:/Ruby193/bin/rake:23:in `<main>' 

的Gemfile:

source 'https://rubygems.org' 

gem 'rails', '3.2.9' 

# Bundle edge Rails instead: 
# gem 'rails', :git => 'git://github.com/rails/rails.git' 

gem 'mysql2' 

gem 'json' 

# Gems used only for assets and not required 
# in production environments by default. 
group :assets do 
    gem 'sass-rails', '~> 3.2.3' 
    gem 'coffee-rails', '~> 3.2.1' 

    # See https://github.com/sstephenson/execjs#readme for more supported runtimes 
    # gem 'therubyracer', :platforms => :ruby 

    gem 'uglifier', '>= 1.0.3' 
end 

gem 'jquery-rails' 

# To use ActiveModel has_secure_password 
gem 'bcrypt-ruby', '~> 3.0.0' 

# To use Jbuilder templates for JSON 
# gem 'jbuilder' 

# Use unicorn as the app server 
# gem 'unicorn' 

# Deploy with Capistrano 
gem 'capistrano' 

# To use debugger 
# gem 'ruby-debug' 
+0

應用程序,你能後的痕跡?你的gemfile是什麼樣的? – 2013-01-04 02:58:49

+0

當然,如果你認爲這將有所幫助,謝謝你的期待。 – mschultz

+0

您是否嘗試過指定'gem「mysql2」,「〜> 0.2.7」'然後運行'bundle install' – 2013-01-05 19:02:01

回答

0

如果我可以推薦。

http://railsinstaller.org/

就是要安裝軌道的最簡單方法。只要確保它匹配正確的系統軟件。

但是,我不認爲這是你的安裝。我認爲這是你改變你的數據庫。首先,我建議使用PG,我認爲它比sql2或sql3好很多。

但是,由於某種原因,你想要sql2,我認爲你修改的database.yml是關閉的。您表示這是正確的,但您可能需要仔細檢查一下。

我不是專家,但也許在這裏有幫助。否則,祝你好運!

+0

我也在MacOS和基於Ubuntu的服務器上運行這個完全相同的rails代碼與git回購),它似乎在這兩種環境中運行得很好。我選擇了使用PostgreSQL上MySQL2 gem的MySQL,因爲它的簡單性和我的經驗 - 對切換到pg不感興趣,而且SQLite不適用於大型數據庫。 我也非常喜歡手動導軌安裝(gem install rails),因爲這使得它與其他系統類似。 – mschultz

2

進出口使用railsinstaller 解決辦法:你要添加的libmysql.dll到Ruby斌,順便說一句,從束installator它的提示,如果你要創建一個擁有--database = mysql的參數

+1

只需將libmysql.dll複製到Ruby bin即可。解決我的問題。 – Domus71