Rails无法使用mysql生成模型

时间:2011-11-20 23:55:20

标签: mysql ruby-on-rails database rubygems mysql2

安装了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 路得"' (成功安装了gem mysql2) rails new talk -d mysql(成功创建了一个名为talk的新rails应用程序)


问题现在开始:


C:\ Sites \ RP \ talk> rails生成用户 错误信息: ruby.exe - 无法找到组件 此应用程序无法启动,因为找不到libmysql.dll。重新安装应用程序可能会解决此问题。 命令行错误消息: C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/mysql2-0.3.10/lib/mysql2.rb :9: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'         来自C:/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块(2级)in require'         来自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'         来自C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.1.0 /lib/rails/commands.rb:21:in require' from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.1.0 /lib/rails/commands.rb:21:in'         来自script / rails:6:require' from script/rails:6:in'

2 个答案:

答案 0 :(得分:1)

http://www.ruby-forum.com/topic/150580有答案。出于某种原因,我需要:

1 / gem install mysql 2 /从/ MYSQL / MySQL Server 5.5 / lib复制libmysql.dll文件并将其粘贴到Ruby1.9.2 / bin

之后,一帆风顺......

即使我这样做了,如果有人能够深入了解背后的原因,我将不胜感激:

答案 1 :(得分:0)

在Windows上应该有一个LIB环境变量。您是否已检查以确保已将libmysql的路径添加到此?我怀疑它没有。