【问题标题】:Rails cannot generate model using mysqlRails 无法使用 mysql 生成模型
【发布时间】:2012-01-02 14:21:15
【问题描述】:

安装了 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 服务器 5.5\lib" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.5\inc lude"' (成功安装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:inblock (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:inblock in require' 来自 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:inrequire' 来自 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' 来自脚本/rails:6:in require' from script/rails:6:in'

【问题讨论】:

  • ruby-forum.com/topic/150580 有答案。出于某种原因,我需要: 1/ gem install mysql 2/ 从 /MYSQL/MySQL Server 5.5/lib 复制 libmysql.dll 文件并将其粘贴到 Ruby1.9.2/bin 之后,它是一帆风顺的......即使我做到了,如果有人能深入了解解决方案背后的原因,我将不胜感激。

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


【解决方案1】:

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

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

之后就一帆风顺了……

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-26
      • 2012-01-12
      相关资源
      最近更新 更多