ERROR: Failed to build gem native extension - Error installing mysql2

user2951937 picture user2951937 · Nov 4, 2013 · Viewed 26.9k times · Source

error while running bundle install

Installing mysql2 (0.3.11) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
...
Make sure that `gem install mysql2 -v '0.3.11'` succeeds before bundling.

when i run Make sure that gem install mysql2 -v '0.3.11'.I still get the same error.

Answer

ben picture ben · Nov 4, 2013

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 http://mxcl.github.com/homebrew/, 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.