3

After I installed ruby 1.9.2p290(with rubyInstaller) on windows 7 and connected MySQL to it ( I checked it and it worked ) I installed rails then I create a project on

"C:\Users\Amiref\Documents\Sites\simple_cms"

with this order : "rails new simple_cms -d mysql" then when I use "rails server" to run webrick I saw this error on command prompt :

"rails.bat :
C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.rb:2:in
`require': Incorrect MySQL client library version! This gem was compile
d for 6.0.0 but the client library is 5.1.45. (RuntimeError)
At line:1 char:6
+ rails <<<<  server
+ CategoryInfo          : NotSpecified: (C:/Ruby192/lib/...
(RuntimeError):String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError

from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.rb:2:in
`<top (required)>'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2.rb:9:in
`require'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2.rb:9:in
`<top (required)>'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in
`require'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in
`block (2 levels) in require'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in
`each'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in
`block in require'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in
`each'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in
`require'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler.rb:122:in
`require'
from
C:/Users/Amiref/Documents/Sites/simple_cms/config/application.rb:7:in
`<top (required)>'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/commands.rb:52:in
`require'
 from
 C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/commands.rb:52:in
`block in <top (required)>'
 from
 C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/commands.rb:49:in
 `tap'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/commands.rb:49:in
`<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
"
ainternet73
  • 117
  • 2
  • 8
  • "Incorrect MySQL client library version! This gem was compiled for 6.0.0 but the client library is 5.1.45." – Phrogz Dec 08 '11 at 23:08
  • If i know, how I can solve this prblem , I never ask it . now If you know how I can solve it then help me. – ainternet73 Dec 08 '11 at 23:11
  • Install an updated version of MySQL? Install an older version of the gem? – Phrogz Dec 08 '11 at 23:13
  • I went to mysql site and installed the latest version that is available on the site and it was mysql 5.5 but now I don't understand why rails give such a message. If I remove 1)ruby 2)ruby on rails 3)mysql 5.5 and reinstall them , Can I hope to solve that error? – ainternet73 Dec 08 '11 at 23:18

3 Answers3

12

The newest rails or ruby use mysql-connector-c-6 (libmysql.dll) compile mysql2-0.3.11-x86-mingw32, so you should use the 6 client dll.

There is a easy way to let RailsInstaller(Ruby1.9.2) use mysql-connector-c-6:

  1. download mysql-connector-c-noinstall-6.0.2-win32.zip
  2. Unzip the mysql-connector-c-noinstall-6.0.2-win32.zip and copu mysql-connector-c-noinstall-6.0.2-win32\lib\libmysql.dll to RailsInstaller\Ruby1.9.2\bin

Then run rails server and everything is OK.

Tom van der Woerdt
  • 29,532
  • 7
  • 72
  • 105
Yand Liu
  • 121
  • 2
  • You can download the mysql connector from the following link: http://dev.mysql.com/downloads/connector/c/ – dsr Jan 03 '12 at 08:39
  • When you gem install mysql2, it displays a helpful message telling you this and even gives you the above link to the correct version of libmysql.dll. However, if you install the gem with bundler, bundler eats the message! – antinome Feb 28 '12 at 04:13
2

Read the error message. Your MySQL gem expects version 6.0.0, but you have 5.1.45 installed.

Jamison Dance
  • 19,896
  • 25
  • 97
  • 99
2

This is caused because a gem (probably either mysql or mysql2) was used in your project and the binaries of that gem were compiled against a different version of MySQL than the one you have installed.

Both mysql and mysql2 gems depends on you having libmysql.dll library in the PATH, which could differ from the one used to build those gems.

Most likely you used Bundler to install those gems, which chewed the installation notes about where to get that particular version of libmysql.dll

I would recommend you remove the installed mysql, mysql2 gems along the libmysql.dll you have somewhere in your PATH and follow the instructions described here:

http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/

You can skip the installation of MySQL itself, but pay attention to the usage of MySQL Connector/C binaries (zip archive, not the installer) and how to install it.

Once you've completed the installation of either mysql or mysql2 gem (the install instructions work for both), please update your bundle:

bundle check

So it reflects the local installed version.

Hope that helps.

Luis Lavena
  • 10,348
  • 1
  • 37
  • 39