Ruby gem mysql2 install failing [duplicate]

Ubuntu: sudo apt-get install libmysqlclient-dev #(mysql development headers) sudo gem install mysql2 — –with-mysql-dir=/etc/mysql/ That’s it! Result: Building native extensions. This could take a while… Successfully installed mysql2-0.2.6 1 gem installed Installing ri documentation for mysql2-0.2.6… Enclosing class/module ‘mMysql2’ for class Result not known Enclosing class/module ‘mMysql2’ for class Client not known Installing RDoc documentation … Read more

rails server fails to start with mysql2 using rvm & ruby 1.9.2-p0 on OSX 10.6.5

The problem comes from the mysql2 gem missing the dynamic library from MySQL. A cleaner solution than install_name_tool … would need to update your DYLD_LIBRARY_PATH to add MySQL libs to it. To do so, update your ~/.bash_profile to add the MySQL library folder : export DYLD_LIBRARY_PATH=”/usr/local/mysql/lib:$DYLD_LIBRARY_PATH” Note: You might want to update the MySQL location … Read more

Ruby MYSQL2 gem installation on windows 7

EDIT 30/09/2014 When this answer was posted the 64 bit rails installer wasn’t the recommended version – it now seems people are starting to use it more. It should be noted when you download the MySQL Connector you need to download either 64 or 32bit to correspond to the version of rails you installed. Amazingly … Read more

mysql2 gem compiled for wrong mysql client library

Uninstalling and reinstalling the gem will often solve this issue with no need to download and move files around by hand. From your rails app directory: > gem uninstall mysql2 You have requested to uninstall the gem: mysql2-0.3.11 database_cleaner-0.9.1 depends on [mysql2 (>= 0)] If you remove this gems, one or more dependencies will not … Read more

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 … Read more