Using MySQL in Ruby

Source: Internet
Author: User
The following error extconf. rb: 2: in 'require is prompted when installing mysql2 using gem.

The following error extconf. rb: 2: in 'require is prompted when installing mysql2 using gem.

1. When installing mysql2 using gem, the following error extconf. rb: 2: in 'require ': no such file to load -- mkmf (LoadError) from extconf. rb: 2 is prompted.

Building native extensions. This cocould take a while...

ERROR: Error installing mysql2:

ERROR: Failed to build gem native extension.

/Usr/bin/ruby1.8 extconf. rb

Extconf. rb: 2: in 'require ': no such file to load -- mkmf (LoadError)

From extconf. rb: 2

Cause: mkmf is missing. mkmf. rb is part of the ruby1.8-dev package.

Solution: sudo apt-get install ruby1.8-dev

2. WARNING: This version of mysql2 (0.3.2) doesn't ship with the ActiveRecord adapter bundled anymore as it's now part of Rails 3.1

WARNING: Please use the 0.2.x releases if you plan on using it in Rails <= 3.0.x

Cause: the rails version is earlier than 3.1, and mysql2 is later than 0.3, resulting in version incompatibility;

Solution: In Gemfile, reduce the version of mysql2 to 'mysql2', '<0.3', or install an exact version using the gem install mysql2-v 0.2.7, set mysql2 to this version in gemfile, or upgrade rails to version 3.1 or later. This method is not verified.

3. Installing mysql2 (0.3.6) D:/develop/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/defaults/operating_system.rb: 9: in 'block in

Op (required)> ': The 'mysql2' native gem requires installed build tools. (Gem: InstallError)

Cause: Unable to install mysql2 because devkit is missing;

Solution: Go to 'HTTP: // rubyinstaller.org/downloads to download the devkit, install the test according to the instructions, and then execute.

4. Install mysql2 and report ERROR: Failed to build gem native extension. The details are as follows:

Building native extensions. This cocould take a while...

ERROR: Error installing mysql2:

ERROR: Failed to build gem native extension.

Google found that many people can install mysql's own parameters during installation ,, for example, include -- with-mysql-lib =$ {mysqlLibPath} Or -- with-mysql-dir =$ {mysqlDir} Or -- with-mysql-config =$ {mysqlConfigPath }. I have tried the same thing before. Finally, I installed a mysql Development Kit libmysqlclient-dev from apt to install mysql successfully on gem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.