我想讓我的Rails應用程序與MySQL一起工作,而不是默認的SQLite。我創建了一個新的項目,強制使用似乎正常工作的MySQL。無法讓Rails服務器與MySQL一起工作
它添加在寶石文件寶石條目這樣:
source 'https://rubygems.org'
gem 'rails', '3.2.13'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2'
當我運行bundle命令它表明其用mysql寶石:
Using mysql2 <0.3.11>
我也配置database.yml文件,像這樣:
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: dbname
pool: 5
username: uname
password: pass
host: hostname
test:
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: dbname
pool: 5
username: uname
password: pass
host: hostname
production:
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: dbname
pool: 5
username: uname
password: pass
host: hostname
但是當我嘗試運行軌道服務器我得到這個:
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/l ib/mysql2/mysql2.rb:2:in
require': 126: The specified module could not be found . - C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-min gw32/lib/mysql2/1.9/mysql2.so (LoadError) from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11- x86-mingw32/lib/mysql2/mysql2.rb:2:in
' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11- x86-mingw32/lib/mysql2.rb:9:inrequire' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11- x86-mingw32/lib/mysql2.rb:9:in
' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.4/ lib/bundler/runtime.rb:72:inrequire' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.4/ lib/bundler/runtime.rb:72:in
block (2 levels) in require' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.4/ lib/bundler/runtime.rb:70:ineach' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.4/ lib/bundler/runtime.rb:70:in
block in require' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.4/ lib/bundler/runtime.rb:59:ineach' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.4/ lib/bundler/runtime.rb:59:in
require' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.4/ lib/bundler.rb:132:inrequire' from C:/Users/n00151956/Desktop/RubyProjects/Demo/config/application.rb: 7:in
' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 3/lib/rails/commands.rb:53:inrequire' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 3/lib/rails/commands.rb:53:in
block in ' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 3/lib/rails/commands.rb:50:intap' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 3/lib/rails/commands.rb:50:in
' from script/rails:6:inrequire' from script/rails:6:in
'
我能得到默認的SQLite運行軌道服務器,但對我的生活,我不能讓它使用MySQL。如果有人能幫助我,這將是很大的幫助!
由於從
嘗試運行'捆綁高管軌server' – tolgap
它返回同樣的事情。 – Nick
你有沒有下載** MySQL Connector/C **,然後將'libmysql.dll'從它拷貝到你的railsinstaller安裝中? –