简体   繁体   English

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

[英]LoadError trying to use MySQL with Ruby on Rails in Windows, RubyMine IDE

I am getting the following error when trying to run a simple Ruby on Rails application from RubyMine: 尝试从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)

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. 此外,我运行'bundle install',将mysql与项目相关联,以及我能找到的其他所有内容。 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. 网上有一些建议,libmysql.dll需要在特定目录中 - 但没有迹象表明获取该特定文件。

Does anyone know how to fix this problem? 有谁知道如何解决这个问题? Thanks! 谢谢!

I fixed a similar error by copying libmysql.dll to the "bin" directory. 我通过将libmysql.dll复制到“bin”目录修复了类似的错误。 In your case copy libmysql.dll to C:\\Ruby192\\bin 在您的情况下,将libmysql.dll复制到C:\\ Ruby192 \\ bin

libmysql.dll gets installed when you intall MySql. 在您安装MySql时会安装libmysql.dll。 The location of the file depends on whether you are using WAMP, XAMPP or just MySql. 文件的位置取决于您使用的是WAMP,XAMPP还是仅使用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. 如果你找不到它在你的计算机上搜索它,当然我假设你已经安装了MySql并且它正在运行。

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'. 为了解决这个错误,我将“libmySQL.dll”文件从“C:\\ Program Files \\ MySQL \\ MySQL Server 5.1 \\ bin”复制到“C:\\ Ruby192 \\ bin”。 For details, refer to post - http://rorguide.blogspot.com/2011/03/getting-error-specified-module-could.html 有关详细信息,请参阅post- http://rorguide.blogspot.com/2011/03/getting-error-specified-module-could.html

我从这里复制了mysql-connector-c-6.1.5-win32.zip\\mysql-connector-c-6.1.5-win32\\lib libmysql.dll http://dev.mysql.com/downloads/connector/c /到ruby bin目录,使其工作

How to install ruby on rails on windows machine with mysql (wamp) 如何使用mysql(wamp)在windows机器上的rails上安装ruby

  1. install rails installer 安装rails安装程序
  2. solve the https certificate issue by using these commands ( source ) 使用这些命令解决https证书问题( 来源

     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. 确保为i386而不是x64位安装了ruby,同样适用于wamp。

  4. install the gem locating the mysql lib file 安装定位mysql lib文件的gem

     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: 当您尝试使用命令rails server实例化服务器时,它将为您提供大量的mysql错误,但不要担心还有一个步骤可以解决它:
    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 转到mysql的lib目录: C:\\wamp\\bin\\mysql\\mysql5.6.17\\lib复制libmysql.dll并将其粘贴到ruby的bin文件夹中,在我的例子中,它是C:\\RailsInstaller\\Ruby2.1.0\\bin

I hope everything will work fine. 我希望一切都会好起来的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM