Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am making one application using RoR with mysql.I followed the below steps for making app with mysql.

1-rails new projectname -d mysql

2-rails generate scaffold Post title:string body:text

After running the 2nd step I got the following error.

Error:

Failed to load libmysql.dll from C:Ruby193lib
ubygems1.9.1gemsmysql2-0.3.
18-x86-mingw32vendorlibmysql.dll

I have installed mysql in my system and copied the libmysql.dll file from mysql-connector-c-noinstall-6.0.2-win32liblibmysql.dll to C:Ruby193in still i am getting the above error.Please try to help me to resolve 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 am using Rails version-3.2.19 and win-xp in my system.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.0k views
Welcome To Ask or Share your Answers For Others

1 Answer

After some "Google Work" and try on a Win2k3 Server, it seems like a problem case by "binary version of mysql2".

In recent versions of mysql2, it contains libmysql.dll unlike before it need to compile locally, and the version of libmysql.dll comes from MySQL Connector 6.1.x which remove WinXp/2k3's support.

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

  1. Uninstall your mysql2 gem by gem uninstall mysql2 and remove all mysql2 package
  2. Download a "MySQL Connector/C NoInstall" from MySQL which version should lower than 6.1, in my case is 6.0.2(mysql-connector-c-noinstall-6.0.2-win32.zip), and unzip to a path, such like "D:MySQLConn"
  3. Install mysql2 by this command:gem install mysql2 --platform=ruby -- '--with-mysql-lib="D:MySQLConnlib" --with-mysql-include="D:MySQLConninclude"'
  4. Run Redmine's install `bundle install --without development test'
  5. Check mysql2 gem gem list mysql2
  6. Remove the gem which not "self-compiled"(by step 3), like name "mysql2-0.3.18-x86-mingw32" and make sure there only a "self-compiled" version of mysql2, looks like "mysql2-0.3.18"
  7. Done!

I hope it will helpful for you.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...