Error installing mysql2: Failed to build gem native extension
On Ubuntu/Debian and other distributions using aptitude:
sudo apt-get install libmysql-ruby libmysqlclient-dev
Package libmysql-ruby
has been phased out and replaced by ruby-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:
sudo apt-get install libmysqlclient-dev
On Red Hat/CentOS and other distributions using yum:
sudo yum install mysql-devel
On Mac OS X with Homebrew:
brew install mysql
ERROR: Failed to build gem native extension - Error installing mysql2
which OS are you using?
anyway if you are using ubuntu, from this https://github.com/brianmario/mysql2/issues/8
run:
sudo apt-get install mysql-client libmysqlclient-dev
Otherwise for Mac users,(use brew to install) check this Link, or run:
brew install mysql
then
sudo gem install mysql2
and for windows users check the link below for a solution.
Error installing mysql2: Failed to build gem native extension
I would recommend to use the normal command prompt.
An error occurred while installing mysql2 (0.5.4), and Bundler cannot continue - in rails project
It is an open issue with mysql2 though there is a workaround. Check this thread from GitHub the last comment is the thing you need.
Ruby gem mysql2 install error
Since this keeps coming up on google as on of the top results, I should point out that this answers is from almost 2 years ago. Here is a more updated answer: How to use "mysql2" gem in Rails 3 application on Windows 7?
According to the developer there is a already a reported bug for it and he is working on parting mysql2 over to Windows. As of now - it's still in the works. Use the older mysql driver for now - or use sqlite for local development.
This is from the googlegroups discussion
Blockquote
Hey Erwann,
There's a ticket on the mysql2 issue tracker for Win32 support already
at http://github.com/brianmario/mysql2/issues#issue/8 . You can follow
it for progress; I'm doing my best to get things working smoothly for
you guys. Hang tight! :)
Installing Mysql 2 gem fails
You're installing an older version of the gem (0.4.5). I had the same issue (using 0.4.3). Installing version 0.4.10 solved this for me.
Try this:
gem install mysql2 -v 0.4.10
If that installs cleanly, you'll have to update your Gemfile
to require this version:
gem 'mysql2', '~> 0.4.10'
Don't install a newer version of the gem (i.e. 0.5.x), they won't work with Rails 4 or older releases of Rails 5 (before 5.0.7/5.1.6) (see https://github.com/brianmario/mysql2/issues/950).
Ruby gem mysql2 install failing
You have to have 64-bit MySQL installed on your machine, plus the build tools you get when you install xcode.
Related Topics
Why Should One Use a Http Server in Front of a Framework Web Server
Using Custom To_JSON Method in Nested Objects
Nokogiri Was Built Against Libxml Version 2.7.7, But Has Dynamically Loaded 2.7.3
Why Do People Say That Ruby Is Slow
Ruby: How to Iterate Over a Range, But in Set Increments
How to Do a Safe Join Pathname in Ruby
Routing Nested Resources in Rails 3
How to Combine Overlapping Time Ranges (Time Ranges Union)
How to Deal with the Conflict Between Activesupport::JSON and the JSON Gem
Ruby: File Encryption/Decryption with Private/Public Keys
Installing Jekyll on Ubuntu 14.04
Double-Splat Operator Destructively Modifies Hash - Is This a Ruby Bug
How to Run a Single Rspec Test