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

后端 未结 4 1307
清歌不尽
清歌不尽 2020-12-17 05:30

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-mi         


        
相关标签:
4条回答
  • 2020-12-17 05:53

    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.

    0 讨论(0)
  • 2020-12-17 06:10

    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

    0 讨论(0)
  • 2020-12-17 06:12

    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

    0 讨论(0)
  • 2020-12-17 06:15

    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.

    0 讨论(0)
提交回复
热议问题