2015-04-22 119 views
1

我試圖在Windows 7上安裝Ruby和使用mysql2在Windows mysql2安裝Ruby 7 64位返回錯誤軌道上小號

下載的Windows 7 64位 下載的devkit最新的安裝here,隨後發現了這個步驟here用於安裝的devkit

這樣做創業板安裝導軌

here的指令之後

下載的mysql發現here

現在一切後安裝使用我此行

軌新test_app創建我的應用程序-d mysql的

改變我的目錄到我的新的應用程序

我跑這條線後軌s

我得到這個錯誤

C:\Ruby22-x64\my_test_app>rails s 
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mysql2-0.3.18-x64-mingw32/lib/mysql2/mysq 
l2.rb:2:in `require': cannot load such file -- mysql2/2.2/mysql2 (LoadError) 
     from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mysql2-0.3.18-x64-mingw32/li 
b/mysql2/mysql2.rb:2:in `<top (required)>' 
     from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mysql2-0.3.18-x64-mingw32/li 
b/mysql2.rb:31:in `require' 
     from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mysql2-0.3.18-x64-mingw32/li 
b/mysql2.rb:31:in `<top (required)>' 
     from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.4/lib/bundler/ru 
ntime.rb:76:in `require' 
     from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.4/lib/bundler/ru 
ntime.rb:76:in `block (2 levels) in require' 
     from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.4/lib/bundler/ru 
ntime.rb:72:in `each' 
     from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.4/lib/bundler/ru 
ntime.rb:72:in `block in require' 
     from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.4/lib/bundler/ru 
ntime.rb:61:in `each' 
     from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.4/lib/bundler/ru 
ntime.rb:61:in `require' 
     from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.4/lib/bundler.rb 
:134:in `require' 
     from C:/Ruby22-x64/my_test_app/config/application.rb:7:in `<top (require 
d)>' 
     from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/com 
mands/commands_tasks.rb:78:in `require' 
     from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/com 
mands/commands_tasks.rb:78:in `block in server' 
     from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/com 
mands/commands_tasks.rb:75:in `tap' 
     from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/com 
mands/commands_tasks.rb:75:in `server' 
     from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/com 
mands/commands_tasks.rb:39:in `run_command!' 
     from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/com 
mands.rb:17:in `<top (required)>' 
     from bin/rails:4:in `require' 
     from bin/rails:4:in `<main>' 

我在這裏失蹤的是什麼? mysql2在我的Gemfile裏面。

雖然我沒有將我的導軌連接到我的數據庫或配置database.yml,因爲我找不到有關如何做到這一點的任何說明。

+0

essfully打開你做'捆綁install'?它成功了嗎? – tadman

+0

我沒有安裝任何mysql軟件。雖然我遵循指導mysql連接器 – magicianiam

+0

在導軌新操作期間,我看到一個線束安裝,並且我假設我不必再做這個過程,或者我錯了嗎? – magicianiam

回答

3

基本上following the instructions in here 我剛剛完成安裝從零到64位Windows 7功能齊全。

在你的情況下,問題可能在於版本的寶石mysql2或它的安裝方式;你可以從卸載開始並重新安裝0.2.6版本@see Gediminas answer並檢查GemFile是否有不同的版本。 這把我從煩惱與特定的:

--with-mysql-dir=.... --with-mysql-lib=.... --with-mysql-include=....


無論如何,我將詳細介紹我的清單中的每個步驟,這樣你就可以看看是否有你的安裝不同

注:根據http://rubyinstaller.org/downloads/我選擇2.1 *(不是最後一個),我下載了標準32。因爲64位版本的Ruby在Windows領域相對較新,並且並未將所有軟件包都更新爲與其兼容。要使用這個版本,你需要一些關於編譯器和解決依賴問題的知識,如果你只是想玩這個語言,這可能太複雜了。 紅寶石2.0.0和上述 - >:在同一頁上 另外閱讀mingw64-32-4.7.2

cd C:\DevKit 
ruby dk.rb init 
ruby dk.rb install 
devkitvars.bat 
  • 不要忘記我的情況下複製libmysql.dll,具有相同的名稱安裝MySQL社區5.6我發現了三個不同的dll(在尺寸上)後:
cd \ 
find . -name "libmysql.dll" 
./Program Files/MySQL/MySQL Connector.C 6.1/lib/libmysql.dll 
./Program Files/MySQL/MySQL Server 5.6/lib/libmysql.dll 
./Program Files/MySQL/MySQL Workbench 6.2 CE/libmysql.dll`` 

明確我選擇此選項:

C:>cd C:\Ruby21\bin> 
C:\Ruby21\bin> copy "\Program Files\MySQL\MySQL Server 5.6\lib\libmysql.dll" . 
     1 file(s) copied. 
C:\Ruby21\bin>gem update --system 
... 
[snip] 
... 
C:\Ruby21\bin>gem env 
RubyGems Environment: 
    - RUBYGEMS VERSION: 2.4.6 
    - RUBY VERSION: 2.1.6 (2015-04-13 patchlevel 336) [i386-mingw32] 
    - INSTALLATION DIRECTORY: C:/Ruby21/lib/ruby/gems/2.1.0 
    - RUBY EXECUTABLE: C:/Ruby21/bin/ruby.exe 
    - EXECUTABLE DIRECTORY: C:/Ruby21/bin 
    - SPEC CACHE DIRECTORY: C:/Users/rondadev/.gem/specs 
    - SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData 
    - RUBYGEMS PLATFORMS: 
    - ruby 
    - x86-mingw32 
    - GEM PATHS: 
    - C:/Ruby21/lib/ruby/gems/2.1.0 
    - C:/Users/rondadev/.gem/ruby/2.1.0 
    - GEM CONFIGURATION: 
    - :update_sources => true 
    - :verbose => true 
    - :backtrace => false 
    - :bulk_threshold => 1000 
    - REMOTE SOURCES: 
    - https://rubygems.org/ 
    - SHELL PATH: 
    - C:\DevKit\bin 
    - C:\DevKit\mingw\bin 
    - C:\Ruby21\bin 
    - C:\Windows\system32 
    - C:\Windows 
    - C:\Windows\System32\Wbem 
    - C:\Windows\System32\WindowsPowerShell\v1.0\ 
    - C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\ 
    - C:\Program Files\Microsoft SQL Server\110\Tools\Binn\ 
    - C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\ 
    - C:\Program Files (x86)\MySQL\MySQL Fabric 1.5.4 

準備安裝導軌和創建第一個應用程序:

gem install rails 

gem install mysql2 -v 0.2.6 

rails new test_app -d mysql 

在結束最後一個步驟:

  1. 連接的MySQL Workbench和創建了一個名爲 test_app_development新的模式(以創建一個新的模式,你可以按與缸和一個加號工具欄上的圖標4 ..請參閱下一屏截圖)

  2. 固定的用戶名和密碼在config/database中。陽明海運在sansarp anwser enter image description here

  3. 遷移的數據庫

MySQL Workbench and database migration 遷移模式後,應該是這樣的: enter image description here

  • 執行軌-s

  • succ在瀏覽器中http://localhost:3000

  • ```

    C:\Projects\test_app>rake db:migrate --trace 
    DL is deprecated, please use Fiddle 
    ** Invoke db:migrate (first_time) 
    ** Invoke environment (first_time) 
    ** Execute environment 
    ** Invoke db:load_config (first_time) 
    ** Execute db:load_config 
    ** Execute db:migrate 
    ** Invoke db:_dump (first_time) 
    ** Execute db:_dump 
    ** Invoke db:schema:dump (first_time) 
    ** Invoke environment 
    ** Invoke db:load_config 
    ** Execute db:schema:dump 
    
    C:\Projects\test_app>rails s 
    DL is deprecated, please use Fiddle 
    => Booting WEBrick 
    => Rails 4.2.1 application starting in development on http://localhost:3000 
    => Run `rails server -h` for more startup options 
    => Ctrl-C to shutdown server 
    [2015-04-29 00:20:21] INFO WEBrick 1.3.1 
    [2015-04-29 00:20:21] INFO ruby 2.1.6 (2015-04-13) [i386-mingw32] 
    [2015-04-29 00:20:21] INFO WEBrick::HTTPServer#start: pid=4144 port=3000 
    
    
    Started GET "/" for ::1 at 2015-04-29 00:20:34 +0200 
    Processing by Rails::WelcomeController#index as HTML 
        Rendered C:/Ruby21/lib/ruby/gems/2.1.0/gems/railties-4.2.1/lib/rails/templates 
    /rails/welcome/index.html.erb (0.0ms) 
    Completed 200 OK in 31ms (Views: 15.6ms | ActiveRecord: 0.0ms) 
    
    +0

    我需要安裝connector/python 3.4嗎?在安裝mysql的檢查要求部分期間,它指出手冊,我不知道我是否應該安裝它? – magicianiam

    +0

    @magicianlam:答案更新:添加了屏幕截圖,詳細介紹了mySQL安裝的選項;我所安裝的所有內容都列在答案中,如果我的文件系統需要特殊檢查,請發表評論。 –

    +0

    我剛剛安裝了mysql所需的所有東西,希望它能正常工作,並且我也跟蹤了在截圖中找到的所有內容,但是您能否爲最後一步提供進一步的說明,主要是步驟1至3.謝謝 – magicianiam

    0

    在配置/ database.yml中有如下設置你的開發環境:

    development: 
        adapter: mysql2 
        database: db_name 
        username: your_username 
        password: your_password 
    
    +0

    我如何知道我的db_name,用戶名和密碼? – magicianiam

    +0

    我試過了,仍然得到了與上面相同的錯誤。我的密碼字段是空的。 – magicianiam