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

后端 未结 4 1316
清歌不尽
清歌不尽 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.

提交回复
热议问题