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

邮差的信 提交于 2019-11-29 05:13:19

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.

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

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

Salman

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!