Ruby Install Mysql Gem Windows

  
Ruby Install Mysql Gem Windows Average ratng: 5,8/10 8438votes

Are you attempting to install the mysql gem and you are receiving this error? Fetching: mysql-2.8.1.gem (100%) Building native extensions. This could take a while. ERROR: Error installing mysql: ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb checking for mysql_query() in -lmysqlclient. No checking for main() in -lm. Yes checking for mysql_query() in -lmysqlclient. No checking for main() in -lz.

Ruby Install Mysql Gem Windows

No checking for mysql_query() in -lmysqlclient. No checking for main() in -lsocket. No checking for mysql_query() in -lmysqlclient. No checking for main() in -lnsl. Yes checking for mysql_query() in -lmysqlclient. No checking for main() in -lmygcc.

No checking for mysql_query() in -lmysqlclient. Makita 2030 Manual Planer Jointer Pdf Download. No *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Sterowniki Do Drukarki Hp Psc 1510 All In One Chomikuj.

Check the mkmf.log file for more details. You may need configuration options. Well, we have the solution for you. Your Linux installation requires that the development libraries for MySQL to be installed in order to build the gem. Here is the proper way for install this gem: How to install mysql gem sudo apt-get install libmysql-ruby sudo apt-get install libmysqlclient-dev sudo gem install mysql If you are still having trouble.

Update: mysql gem version `2.9.0` already fix the issues shown here. Install it normally and follow the on-screen instructions. In order to use my brand new MySQL installation, now I need to install the MySQL bindings for it. But, there is a small detail: Ruby is 32bits and my MySQL is 64bits, this means I can't. This package is offered as gem for easy installation using RubyGems. It wraps unmodified tmtm's mysql-ruby extension into a proper gem.

Try installing the development package of Ruby 1.8 (or newer) by using the command below, and then attempt to install the MySQL gem: sudo apt-get install ruby1.8-dev or sudo apt-get install ruby1.9.1-dev.

Recently I reinstalled by entire Windows installation due a SSD migration and wanted to take the opportunity to document the configuration process, specially in the light of the known issues with making it work with Ruby. It is important to mention that most of these issues in Ruby land are generated due the lack of documentation associated on how to properly install MySQL and its related dependencies. Most of us expect things to Just Work, and we often compare the installation process to installing to Linux or OSX which works out of the box. What is not mentioned in the documentation installation is that development tools (a compiler) and specific headers and libraries are required. Unless you’ve already installed them, these development artifacts are usually missing from a Windows computer. What I’m going to describe next is how I installed and configured my environment and how I made it work properly.

YMMV if you decided to use different versions of the components I used for this. Let’s get started: Download the right version of MySQL As I mentioned before, I’m using a 64bits version of Windows, so I think it will be best if I download a matching bits version.

So went ahead and visited MySQL download site: And selected MySQL Community Server 5.5.13. From the versions offered, downloaded Windows (x86, 64-bit), MSI Installer Install MySQL Invoked the installer and presented with the normal installation wizard. You can follow the next sequence of images to use my same settings. Is good to always install your Data files outside the default program installation directory, that way, you can safely upgrade your installation and not to worry about an installer removing your data files. Ok, so let’s move to the next thing Before installing MySQL/Ruby bindings Update: mysql gem version `2.9.0` already fix the issues shown here. Install it normally and follow the on-screen instructions. In order to use my brand new MySQL installation, now I need to install the MySQL bindings for it.

But, there is a small detail: Ruby is 32bits and my MySQL is 64bits, this means I can’t use MySQL provided libraries from Ruby. You told me to install the 64bits version! Don’t despair! MySQL Connector to the rescue! That is right, MySQL has something called Connector, the purpose of that library is to avoid a complete MySQL installation when you just need to connect to a remote one. It comes in different flavors, we are interested in C language support, since that is the language Ruby uses for it’s extensions. We are going to download a 32bits connector and use it!

So, at my web browser again, decided to visit the MySQL Connector/C download page: Since I’m not interested in installing this Connector and pollute my clean 64bits installation, I’m going to download the non-installer version. I scrolled down the listing until I saw the noinstall 32bits version: mysql-connector-c-noinstall-6.0.2-win32.zip Decided to extract it to the root of my disk, so I ended with a folder named mysql-connector-c-noinstall-6.0.2-win32 in there. Remember: extract into a folder without spaces. The same goes for your Ruby installation and the DevKit installation. Time to install MySQL/Ruby bindings So, now that all MySQL prerequisites are in place, will open a new command prompt and prepare to install the gem. This time I’m going to use Ruby 1.9.2, properly installed and configured with the complementary Development Kit (DevKit) which is provided at (In case you haven’t installed yet, don’t forget to follow the ) OK, so in a Command Prompt, will type the gem installation command: gem install mysql --platform=ruby -- --with-mysql-dir=C:/mysql-connector-c-noinstall-6.0.2-win32 Note the use of forward slashes for the directory where MySQL Connector/C was extracted. The above command contains two special things: First, we are telling RubyGems that we want the ruby platform of mysql gem.

This particular platform is the one that contains the source code and this will allow us to skip the pre-compiled version of the gem. The second part, which is added after two dashes, are the additional arguments that we are giving to the gem configuration process to locate our MySQL headers and libraries for successful compilation. As result of this command, you will see something like this: Fetching: mysql-2.8.1.gem (100%) Temporarily enhancing PATH to include DevKit.

Building native extensions. This could take a while.

Successfully installed mysql-2.8.1 1 gem installed Which indicates the gem installed successfully. In case you obtained a different result, please refer to RubyInstaller Troubleshooting page: And try the proposed solutions there. Using the bindings Now that we installed the gem, we can remove the connector folder we first extracted. Before do that, first we need to take out a file from there: libmysql.dll. This file is required by the gem we compiled and needs to be available for it.

You can find it inside the lib directory of MySQL Connector. I personally recommend you place it along your Ruby installation, inside the bin directory. If you have multiple Ruby installations and you use Pik to change between them, you can place the library in the same directory Pik is installed.

You need to remember that it is important the libmysql.dll file is on the PATH when you need to use it. OK, after all that big red warning, let’s test this thing on a IRB console: irb>require 'rubygems' irb>require 'mysql' irb>conn = Mysql.connect 'localhost', 'root', 'abc123' irb>result = conn.query 'SELECT 1' irb>result.num_rows =>1 irb>result.fetch_row =>['1'] irb>result.free irb>conn.close irb>exit Great!, now you have not just a working MySQL installation but also Ruby configured to talk to it! Hope you enjoyed this post as I did enjoy creating it. Hope this ease your path on using MySQL with Ruby on Windows. Awesome Tutorial Bro!!!

I figured that I would post my findings, based on your writings, but tweaked to meet my needs. I already had MySQL-5.6.14-x64 installed, which I installed from a zip file, that I downloaded from the MySQL/Oracle Website here I also downloaded the x32 (or x86) version for experimentation purposes. I then unzipped the x64 version into a directory just off of the root at C:/www/mysql/mysql-x64 (the 32-bit version was obviously unzipped into the “C:/www/mysql/mysql-x32″ directory).

My Ruby/Rails files are located in C:/Ruby-2.0.0-x64” directory (I also have another version of Ruby located in the “C:/Ruby-1.9.3” directory). Needless to say, I didn’t have to use the “MySQL Connector(s)” to connect Ruby to MySQL since I was using 64-bit versions of each program.

Therefore, I used the following command to install the mysql2 gem and connect Ruby 2.0.0 ×64 to MySQL 5.6.14 ×64 C: Ruby200-x64>gem install mysql2 –platform=ruby — –with-mysql-dir=C: wwwhttp mysql mysql-x64 I’ll try to dig up the other tutorials that I used to install Ruby 2.0.0 ×64, Rails, Apache 2.6, SQLite3,MariaDB, NginX and several other related applications and if I remember, I’ll make a follow-up post or perhaps post my research notes/findings to my blog and post a link here 🙂 Thanks again and keep up the killer work!!! Extremely helpful. Lack of documentation on Ruby and windows 7 is a pain. This write-up helped me with exactly what Sjaak Spoiler said: Notice that: – I need to have no spaces – the mysql-dir should point to the connector and not the mysqlserver and it also helped me to realize that I do not need to downgrade mysql from 64bit to 32bit nor do I have to upgrade or downgrade a lot of other software, which was what I was in the process of doing in order to troubleshoot this. Tried so many things and read so many write-ups but none of them are clear or explicit enough nor do they touch upon this exact situation well enough.

I get a failure when running the WEBrick server at the mysql gem.