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 and libmysql.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.
gem install mysql2 --platform=ruby --
--with-mysql-lib="d:\mysql\lib" --with-mysql-include="d:\mysql\include"
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 the libmysql.dll under railsinstaller 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 components
my 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