用安裝了MYSQL的Windows XP作爲開發機器,ruby 1.9.2p290(2011-07-09)[i386-mingw32],Rails 3.1.0 gem install mysql2 - '--with -mysql-lib =「c:\ Program Files \ MySQL \ MySQL S erver 5.5 \ lib」--with-mysql-include =「c:\ Program Files \ MySQL \ MySQL Server 5.5 \ inc lude」'(成功安裝寶石mysql2) 軌新的通話-d mysql的(成功創建了一個新的Rails應用程序稱爲通話)Rails無法使用mysql生成模型
問題從現在開始:
C:\ Sites \ RP \ talk> rails生成用戶 錯誤消息: ruby.exe-無法定位組件 此應用程序未能啓動,因爲未找到libmysql.dll。重新安裝應用程序可能會解決此問題。 命令行錯誤MESSAGE: C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/mysql2-0.3.10/lib/mysql2.rb :9:在選自C require': 126: The specified module could not be found. - C:/RailsInsta ller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/mysql2-0.3.10/lib/mysql2/mysql2.so (Load Error) from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/mysql2-0.3.10/ lib/mysql2.rb:9:in
' : /RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18 /lib/bundler/runtime.rb:68:in require' from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18 /lib/bundler/runtime.rb:68:in
block(2 levels)in require' from C: /RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18 /lib/bundler/runtime.rb:66:in each' from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18 /lib/bundler/runtime.rb:66:in
要求' 中的塊從C:/ RailsInstaller/Ruby1 .9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18 /lib/bundler/runtime.rb:55:in each' from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18 /lib/bundler/runtime.rb:55:in
需要C:/RailsInstaller/Ruby1.9.2/lib/ruby中的' /gems/1.9.1/gems/bundler- 1.0.18 /lib/bundler.rb:120:in require' from C:/Sites/RP/talk/config/application.rb:9:in
' from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.1.0 /lib/rails/commands.rb:21:require' from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.1.0 /lib/rails/commands.rb:21:in
' from script/rails:6:in require' from script/rails:6:in
'
http://www.ruby-forum.com/topic/150580有答案。由於某種原因,我需要: 1/gem install mysql 2 /從/ MYSQL/MySQL Server 5.5/lib複製libmysql.dll文件並將其粘貼到Ruby1.9.2/bin 之後,它便順利航行。 .. 儘管我做到了,但如果有人對解決方案背後的原因有所瞭解,我將不勝感激。 – delta2006