Failed to load libmysql.dll file using Ruby on Rails 3

I am making one application using RoR with mysql.I, following the steps below to create an application using mysql.

1-rails new project name -d mysql

2-rails generate a sketch Post name: string body: text

After completing the second step, I received the following error.

Error:

Failed to load libmysql.dll from C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3. 18-x86-mingw32\vendor\libmysql.dll 

I installed mysql on my system and copied the libmysql.dll file from mysql-connector-c-noinstall-6.0.2-win32 \ lib \ libmysql.dll to C: \ Ruby193 \ bin, but I get the above error. Please try to help I have to solve this error, and I am also interested to know if my mysql DB is present in some other instance instead of my local system, how can I connect it using Rails.

I use Rails version 3.2.19 and win-xp on my system.

+6
source share
3 answers

After some “google work” and try on a Win2k3 server, this seems like a problem using the “binary mysql2 version”.

In recent versions of mysql2, it contains libmysql.dll, unlike it, before it needs to be compiled locally, and the version of libmysql.dll is from MySQL Connector 6.1.x, which removes WinXp / 2k3 support.

So, you can try this way, I have success in my Redmine installation:

  • Uninstall your mysql2 gem with gem uninstall mysql2 and remove the entire mysql2 package
  • Download "MySQL Connector / C NoInstall" from MySQL, the version of which must be lower than 6.1, in my case it is 6.0.2 (mysql-connector-c-noinstall-6.0.2-win32.zip) and unzip a path such as "D : \ MySQLConn "
  • Install mysql2 with this command: gem install mysql2 --platform=ruby -- '--with-mysql-lib="D:\MySQLConn\lib" --with-mysql-include="D:\MySQLConn\include"'
  • Launch Redmine, install `bundle install --without development test '
  • Check mysql2 gem gem list mysql2
  • Remove the gem that is not "compiled" (in step 3), as the name is "mysql2-0.3.18-x86-mingw32" and make sure that there is only a "compiled" version of mysql2, mysql2-0.3.18 "
  • Done!

Hope this helps you.

+10
source

I found out that there are 32-bit and 64-bit variants of libmysql.dll. Give them a try. The 32-bit libmysql.dll worked for me.

+3
source

This happened to me after my upgrade to mysql2 0.4.7+. Versions after 0.4.6 use the MySQL Connector C 6.1.10+. The notes mention that to compile MySQL Connector C you will need Visual C ++ Redistributable for Visual Studio 2015 . After installing this and reinstalling mysql2, the error went away.

+1
source

Source: https://habr.com/ru/post/984496/


All Articles