When try to connect to the mysql server through my rails application, I get the following error
D:/Program_Files/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require':
Incorrect MySQL client library version! This gem was compiled for 6.0.0 but the client library is 5.0.27. (RuntimeError)
How can I rectify it?
I discovered a completely different cause for this problem. I had been using the mysql gem. I built the mysql2 gem but I forgot to update my database.yml. With the mysql2 gem, it needs to say:
rather than
The gem built, but I got the error when I next ran rake.
Obvious once you've seen it, but you get the same error message as discussed here!
By the way, the command to build the mysql2 gem on my machine was a bit more complicated than described above:
To Add to the existing answer. ( windows platform specifically )
Ruby really sucks on top of this. Rails should not actually care about the version of the connector or the mysql version. -- but that's my opinion.
In order to get this **ing thing working, you need 2 things.
mysql2 gem
andlibmysql.dll
and you need to match them up in terms of the version. (this caused confusion for me, because I can see the latest connector is 6.x while mysql is only 5.x, how should I match them up)mysql2 gem. and when you install it you need to specify the connector.
it does not need to be connector downloaded from oracle. all you need is a mysql installation and the
lib
include
folder underneath it. then put thelibmysql.dll
underrailsinstaller bin
folder.if it didn't work to make you install mysql2 gem succesfully => for my case it is because my mysql is too old (why would ruby care that). so I get some latest mysql from oracle. use the
lib
include
libmysql.dll
under it. you don't really need to upgrade your database, you can keep it somewhere and continue to use it after you generated the 2 required componentsmy case: I use a very ancient mysql database and I am unwilling to upgrade it at the moment. so I back that database up and restored it later