I am having some problems when trying to install mysql2
gem for Rails. When I try to install it by running bundle install
or gem install mysql2
it gives me the following error:
Error installing mysql2: ERROR: Failed to build gem native extension.
How can I fix this and successfully install mysql2
?
libmysql-ruby
has been phased out and replaced. New command:Have you tried using
to specify the location of thebase directory as well as the path to the MySQL libraries that are necessary to complete the gem installation?
Sources: MySQL Gem Install ERROR: Failed to build gem native extension MySQL Forums :: Ruby :: Help needed with installing MySQL binding for Ruby
I had this issue with my windows 7. This is apparently an incompatibility issue and the solution is as follows: Download mysql.dll file from an older InstantRails installer. The Link http://tinyurl.com/24ocp8u will download only the mysql.dll file.(It's link to svn repository of InstantRails). Next, copy that filw into your Ruby/bin folder. Now, you are good to go ;)
If still getting error then follow the steps of mysql2 gem installation on Rails 3 on -
http://rorguide.blogspot.com/2011/03/installing-mysql2-gem-on-ruby-192-and.html
where most of the user were able to install mysql2 gem.
On Ubuntu/Debian and other distributions using aptitude:
Package
libmysql-ruby
has been phased out and replaced byruby-mysql
. This is where I found the solution.If the above command doesn't work because
libmysql-ruby
cannot be found, the following should be sufficient:On Red Hat/CentOS and other distributions using yum:
On Mac OS X with Homebrew:
If you are still having trouble….
Try installing