Installing MySQL-2.9.0 Gem on Windows Fails Due to Lack of Libmysql

Installing mysql-2.9.0 gem on Windows fails due to lack of libmysql

Try with no installer version of connector from http://dev.mysql.com/downloads/connector/c/ and extract the content in root folder or a folder path which does not have any space for and then try to install mysql gem

example

gem install mysql --platform=ruby -- --with-mysql-dir=C:/mysql-connector-c-noinstall-6.0.2-win32

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 I lucked upon an answer very early this morning as I happened to be looking for something else of a similar nature. I'm not quite sure why there isn't a single simple guide for this as it appears to be very straight forward!

For some reason just specifying the mysql-dir when you install the gem doesn't pick up with other sub directories so you need to set the parameters manually.

For anyone else experiencing the same problem, I did the following:

1) Download the MySql C Connector from: http://dev.mysql.com/downloads/connector/c/

NOTE Don't download the installer, download the ARCHIVE for your OS

Download either the 32bit or 64 bit ARCHIVE to correspond with the version of rails you installed.

2) Extract the file to C:\mysql-connector

3) Then ran:

 gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\mysql-connector\lib" --with-mysql-include="C:\mysql-connector\include" --with-mysql-dir="C:\mysql-connector"'

Voila everything is working fine.

EDIT 30/01/2014

I just had to do a fresh install on a bricked machine and the command in step 3 didn't work, what did work was:

gem install mysql2 --platform=ruby -- '--with-mysql-dir="C:\mysql-connector"'

I'm not quite sure what the difference is but this time it seems to be picking up the directories ok, so if the first one doesn't work try this one!

I think this has to do with how you go about installing rails, this time round I used the railsinstaller which seems to set the paths up correctly.

A lot of the outcome here seems to depend on the shell your using, a lot of people are having problems with powershell so I wouldn't advise using it. I did this in an elevated command prompt.

Oh and lastly if you get an error regarding the mysql2 gem when you do RAILS S you need to copy the libmysql.dll from the LIB directory of the mysql connector to the bin directory where rails has been installed.

Unable to install MySQL2 gem on Windows 7

The specific version of mysql2 gem you're trying to install (0.2.4) not only lacks binaries for Windows, but have issues on Windows.

Please install mysql2 gem without indicating the version:

gem install mysql2

Which will install latest version (0.2.6 at the time of my posting this) and also provides binaries for Windows which skip the compilation step.

If you still want to force the compilation (because your version of MySQL differs from the one used to generate the binary gem, you will need to install RubyInstaller's DevKit from RubyInstaller website:

http://rubyinstaller.org/downloads

And follow the DevKit installation instructions from our wiki (that is linked from the download page)

You will need to provide the path to both headers and libraries during the gem installation process, and adjust the MySQL installation location from the following instructions:

subst X: "C:\Program Files (x86)\MySQL\MySQL Server 5.1" 
gem install mysql2 --platform=ruby -- --with-mysql-dir=X: --with-mysql-lib=X:\lib\opt
subst X: /D

The above command uses subst to avoid issues with path with spaces, which you should avoid always.

Hope this helps.

Errors Installing mysql2 gem via the Bundler

Answer was similar to the one Wrikken posted -- here's what I did to fix it for the sake of future readers.

(This is for RHEL 5.5 -- similar but different commands apply for Ubuntu/Debian/etc.)

Doing sudo yum list installed will print out all installed packages on your machine (note: yum on RHEL requires you add a Red Hat Network repository [I use EPEL], and run it via sudo).

I had mysql and mysql-server, which explained why MySQL worked fine for every pre-existing app, but no mysql-devel, which is necessary to fix that mysql.h is missing error and similar other build errors.

Long story short, after a mysqldump -u root -ppassword --all-databases > full-dump.sql for safety, it was fixed with a simple

sudo yum install mysql-devel

Installing mysql ruby gem in windows fails using ruby 2.0.0

To get the mysql gem to work the following command for installation was required

gem install mysql --platform=ruby -- --with-opt-dir=C:/mysql-connector-c-noinstall-6.0.2-win32

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! :)

Ruby on Rails installation issue (Windows)

You need MySQL 32-bit (or MySQL Connector C) to compile mysql2 gem compiling on Windows (even if you are using a 64-bit version of the OS).

Follow these steps:

  1. Download MySQL Server 32-bit .zip file (Alternatively MySQL Connector C is also fine)
  2. Copy libmysql.dll to %RUBY_HOME%\bin (or simply add MySQL 32-bit lib directory to PATH)
  3. Install mysql2 gem with --with-mysql-lib and --with-mysql-include options

    gem install mysql2 -- '--with-mysql-lib="c:\path\to\32-bit-MySQL-Server\lib\opt" --with-mysql-include="c:\\path\to\32-bit-MySQL-Server\include"'


Related Topics



Leave a reply



Submit