我一直試圖在Ruby on Rails上使用SQL很長一段時間,似乎無法使它工作。加載錯誤 - 在Ruby on Rails中使用MySQL
我幾乎已經放棄了SQLite,所以我現在的重點是MySQL。我已經完全安裝了該程序,並且可以自行運行。但是我無法讓它與Ruby on Rails一起工作。
以下是當我開始一個新項目並選擇MySQL作爲數據庫時得到的消息。
C:\rails_projects>rails new first2_app -d mysql
create
create README.rdoc
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/assets/images/rails.png
create app/assets/javascripts/application.js
create app/assets/stylesheets/application.css
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create app/views/layouts/application.html.erb
create app/mailers/.gitkeep
create app/models/.gitkeep
create config
create config/routes.rb
create config/application.rb
create config/environment.rb
create config/environments
create config/environments/development.rb
create config/environments/production.rb
create config/environments/test.rb
create config/initializers
create config/initializers/backtrace_silencers.rb
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/initializers/secret_token.rb
create config/initializers/session_store.rb
create config/initializers/wrap_parameters.rb
create config/locales
create config/locales/en.yml
create config/boot.rb
create config/database.yml
create db
create db/seeds.rb
create doc
create doc/README_FOR_APP
create lib
create lib/tasks
create lib/tasks/.gitkeep
create lib/assets
create lib/assets/.gitkeep
create log
create log/.gitkeep
create public
create public/404.html
create public/422.html
create public/500.html
create public/favicon.ico
create public/index.html
create public/robots.txt
create script
create script/rails
create test/fixtures
create test/fixtures/.gitkeep
create test/functional
create test/functional/.gitkeep
create test/integration
create test/integration/.gitkeep
create test/unit
create test/unit/.gitkeep
create test/performance/browsing_test.rb
create test/test_helper.rb
create tmp/cache
create tmp/cache/assets
create vendor/assets/javascripts
create vendor/assets/javascripts/.gitkeep
create vendor/assets/stylesheets
create vendor/assets/stylesheets/.gitkeep
create vendor/plugins
create vendor/plugins/.gitkeep
run bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.0.4)
Using i18n (0.6.1)
Installing multi_json (1.7.3)
Using activesupport (3.2.13)
Using builder (3.0.4)
Using activemodel (3.2.13)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.5)
Using rack-cache (1.2)
Using rack-test (0.6.2)
Using hike (1.2.2)
Installing tilt (1.4.1)
Using sprockets (2.2.2)
Using actionpack (3.2.13)
Using mime-types (1.23)
Using polyglot (0.3.3)
Using treetop (1.4.12)
Installing mail (2.5.4)
Using actionmailer (3.2.13)
Using arel (3.0.2)
Using tzinfo (0.3.37)
Using activerecord (3.2.13)
Using activeresource (3.2.13)
Using bundler (1.3.5)
Using coffee-script-source (1.6.2)
Using execjs (1.4.0)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.3)
Installing json (1.8.0)
Using rdoc (3.12.2)
Using thor (0.18.1)
Using railties (3.2.13)
Using coffee-rails (3.2.2)
Using jquery-rails (2.2.1)
Installing mysql2 (0.3.11)
Using rails (3.2.13)
Installing sass (3.2.9)
Using sass-rails (3.2.6)
Installing uglifier (2.1.0)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
Post-install message from mysql2:
================================================================================
======================
You've installed the binary version of mysql2.
It was built using MySQL Connector/C version 6.0.2.
It's recommended to use the exact same version to avoid potential issues.
At the time of building this gem, the necessary DLL files where available
in the following download:
http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0
.2-win32.zip/from/pick
And put lib\libmysql.dll file in your Ruby bin directory, for example C:\Ruby\
bin
================================================================================
======================
然而,當我繼續運行軌道服務器,我收到以下錯誤:
C:\rails_projects\first2_app>rails server
C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.rb:2:
in `require': cannot load such file -- mysql2/2.0/mysql2 (LoadError)
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.rb:2:
in `<top (required)>'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2.rb:9:
in `require'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2.rb:9:
in `<top (required)>'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:
in `require'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:
in `block (2 levels) in require'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:
in `each'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:
in `block in require'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:
in `each'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:
in `require'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler.rb:132:
in `require'
from C:/rails_projects/first2_app/config/application.rb:7:
in `<top (required)>'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/commands.rb:53:
in `require'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/commands.rb:53:
in `block in <top (required)>'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/commands.rb:50:
in `tap'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/commands.rb:50:
in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
我已經試過幾乎所有我所遇到的相關StackExchange的問題/解答包括RubyVersionManager,的devkit,將各種.dll和.a文件移動到C/Ruby/Bin等等,但沒有多少運氣。
任何意見將不勝感激!我真的要開始使用Ruby on Rails的編程和恨,我被困在門口....
乾杯= d
更新1:(嘗試在Linux環境中)
你好,共識似乎試圖在Linux中運行。
所以我也跟着上使用Cygwin>http://youtu.be/hwo3Eda_ev0
這傢伙的指示,一切都進展順利,到目前爲止=)
我對Windows上的Ruby on Rails瞭解不多,但是您是否嘗試過安裝gem mysql2的消息?無論如何,如果您是RoR的初學者,我建議您嘗試使用Linux,這非常容易,您將來可以減少頭痛的次數:)。 – Pigueiras
完全同意@Pigueiras,不應該在Windows上使用Rails。我自己是一個Windows用戶,但是在工作和家中的虛擬機中開發Mac的軌道 – kasperite
在這一點上願意嘗試任何東西。我會回覆使用Linux的進度 –