LoadError 尝试在 Windows、RubyMine IDE 中将 MySQL 与 Ruby on Rails 一起使用

发布于 2024-10-19 15:12:30 字数 477 浏览 1 评论 0原文

当尝试从 RubyMine 运行简单的 Ruby on Rails 应用程序时,我收到以下错误:

C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/mysql2/mysql2.rb:2:in `require': 126: The specified module could not be found.   
C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/mysql2/1.9/mysql2.so (LoadError)

问题是,该文件实际上在那里。此外,我还运行了“bundle install”,将 mysql 与项目关联起来,以及我能找到的所有其他内容。网上有一些建议认为 libmysql.dll 需要位于特定目录中 - 但没有指示获取该特定文件。

有谁知道如何解决这个问题?谢谢!

I am getting the following error when trying to run a simple Ruby on Rails application from RubyMine:

C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/mysql2/mysql2.rb:2:in `require': 126: The specified module could not be found.   
C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/mysql2/1.9/mysql2.so (LoadError)

The thing is, that file is actually there. Further, I've run 'bundle install', associated the mysql with the project, and everything else I can find. There is some suggestion on the net that libmysql.dll needs to be in a particular directory - but no indication to get that particular file.

Does anyone know how to fix this problem? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

情定在深秋 2024-10-26 15:12:30

我通过将 libmysql.dll 复制到“bin”目录来修复类似的错误。在您的情况下,将 libmysql.dll 复制到 C:\Ruby192\bin

libmysql.dll 在您安装 MySql 时安装。文件的位置取决于您使用的是 WAMP、XAMPP 还是仅使用 MySql。如果你找不到它,请在你的计算机上搜索它,当然我在这里假设你已经安装了 MySql 并且它正在运行。

I fixed a similar error by copying libmysql.dll to the "bin" directory. In your case copy libmysql.dll to C:\Ruby192\bin

libmysql.dll gets installed when you intall MySql. The location of the file depends on whether you are using WAMP, XAMPP or just MySql. If you can't locate it search for it on your computer, ofcourse I assume here that you have MySql installed and that its running.

書生途 2024-10-26 15:12:30

谢谢,我能够修复错误。为了修复此错误,我将“libmySQL.dll”文件从“C:\Program Files\MySQL\MySQL Server 5.1\bin”复制到“C:\Ruby192\bin”。有关详细信息,请参阅帖子 - http://rorguide。 blogspot.com/2011/03/getting-error-specified-module-could.html

Thanks, I was able to fix the error. To fix this error, I copied "libmySQL.dll" file from 'C:\Program Files\MySQL\MySQL Server 5.1\bin' to 'C:\Ruby192\bin'. For details, refer to post - http://rorguide.blogspot.com/2011/03/getting-error-specified-module-could.html

无畏 2024-10-26 15:12:30

我从这里复制了 libmysql.dll mysql-connector-c-6.1.5-win32.zip\mysql-connector-c-6.1.5-win32\lib < a href="http://dev.mysql.com/downloads/connector/c/" rel="nofollow">http://dev.mysql.com/downloads/connector/c/ 到 ruby​​ bin使其工作的目录

I copied libmysql.dll from mysql-connector-c-6.1.5-win32.zip\mysql-connector-c-6.1.5-win32\lib from here http://dev.mysql.com/downloads/connector/c/ to ruby bin directory to make it working

蓝梦月影 2024-10-26 15:12:30

如何使用 mysql (wamp) 在 Windows 计算机上安装 ruby​​ on Rails

  1. 安装 Rails 安装程序
  2. 使用这些命令解决 https 证书问题 (来源)

    ruby“C:\RailsInstaller\win_fetch_cacerts.rb”
    设置 SSL_CERT_FILE=C:\RailsInstaller\cacert.pem
    
  3. < p>确保你安装了 i386 的 ruby​​,而不是 x64 位,wamp 也是如此。

  4. 安装gem并定位mysql lib文件

    gem install mysql2 -- '--with-mysql-lib="C:\wamp\bin\mysql\mysql5.6.17\lib" --with-mysql-include="C:\wamp\ bin\mysql\mysql5.6.17\include"'
    
  5. 现在,当您创建应用程序时,请使用以下命令:

    rails new APPNAME -d mysql
    
  6. 当您尝试使用命令rails server 实例化服务器时,它会给您大量 mysql 错误,但不要不用担心,还有一个步骤可以解决这个问题:
    进入mysql的lib目录:C:\wamp\bin\mysql\mysql5.6.17\lib
    复制 libmysql.dll 并将其粘贴到 ruby​​ 的 bin 文件夹中,在我的例子中,它是 C:\RailsInstaller\Ruby2.1.0\bin

我希望一切顺利工作正常。

How to install ruby on rails on windows machine with mysql (wamp)

  1. install rails installer
  2. solve the https certificate issue by using these commands (source)

    ruby "C:\RailsInstaller\win_fetch_cacerts.rb"
    set SSL_CERT_FILE=C:\RailsInstaller\cacert.pem
    
  3. make sure that you have ruby installed for i386 not x64 bit, same goes for the wamp as well.

  4. install the gem locating the mysql lib file

    gem install mysql2 -- '--with-mysql-lib="C:\wamp\bin\mysql\mysql5.6.17\lib" --with-mysql-include="C:\wamp\bin\mysql\mysql5.6.17\include"'
    
  5. Now, when you create your app, use the following command:

    rails new APPNAME -d mysql
    
  6. When you will try to instantiate the server by using the command rails server, it will give you tonnes of mysql errors, but don't worry there is one more step which can solve it:
    go to the lib directory of mysql: C:\wamp\bin\mysql\mysql5.6.17\lib
    copy the libmysql.dll and paste it into the bin folder of your ruby, in my case, it is C:\RailsInstaller\Ruby2.1.0\bin

I hope everything will work fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文