Questions tagged [mysql2]

The Mysql2 gem is meant to serve the extremely common use-case of connecting, querying and iterating on results.

The mysql2 gem is an interface for accessing MySQL databases from Ruby. This gem is an incompatible improvement over the original mysql gem.

Links:

907 questions
527
votes
33 answers

Error installing mysql2: Failed to build gem native extension

I am having some problems when trying to install mysql2 gem for Rails. When I try to install it by running bundle install or gem install mysql2 it gives me the following error: Error installing mysql2: ERROR: Failed to build gem native…
spacemonkey
  • 19,664
  • 14
  • 42
  • 62
153
votes
10 answers

Rails 4 - Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded

In my gemfile I have: gem 'mysql2' My database.yml is as follows: default: &default adapter: mysql2 database: <%= ENV['db_name'] %> username: <%= ENV['db_user'] %> password: <%= ENV['db_pass'] %> host: <%= ENV['db_host'] %> pool:…
105
votes
18 answers

Error when trying to install app with mysql2 gem

Im trying to install an open source rails 3.2.21 application that uses the mysql2 gem, but when i try and run the bundle commant I get the following error: Fetching: mysql2-0.3.18.gem (100%) Building native extensions. This could take a…
zenvelope
  • 1,274
  • 2
  • 9
  • 13
104
votes
14 answers

Gem::LoadError for mysql2 gem, but it's already in Gemfile

Gem::LoadError Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile This error occurred while loading the following files: active_record/base This is the error I get on running rails server. The…
Mysoulisinseoul
  • 1,061
  • 2
  • 7
  • 7
90
votes
13 answers

LEFT OUTER JOIN in Rails 4

I have 3 models: class Student < ActiveRecord::Base has_many :student_enrollments, dependent: :destroy has_many :courses, through: :student_enrollments end class Course < ActiveRecord::Base has_many :student_enrollments, dependent:…
Khanetor
  • 11,595
  • 8
  • 40
  • 76
83
votes
11 answers

Ruby gem mysql2 install failing

When I try to install the mysql2 gem, it fails with no apparent errors. Does anyone know what to do to work around this so mysql2 installs? $ sudo gem install mysql2 Building native extensions. This could take a while... ERROR: Error installing…
Tanner
  • 1,214
  • 3
  • 12
  • 16
65
votes
8 answers

mysql2 gem compiled for wrong mysql client library

When try to connect to the mysql server through my rails application, I get the following error D:/Program_Files/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': Incorrect MySQL client library version! This gem was…
Rahul
  • 44,892
  • 25
  • 73
  • 103
61
votes
6 answers

What is the difference between MySQL & MySQL2 considering NodeJS

I have read the following: What the difference between mysql and mysql2 gem So far I have only used MongoDB with NodeJS and I want to be able to learn MySQL for any of my relational database needs. While researching MySQL & NodeJS I have found…
Eric Bishard
  • 5,201
  • 7
  • 51
  • 75
49
votes
8 answers

Mysql 5.6 headaches on Mac OSX

Several of my colleagues and I have recently upgraded from MySQL 5.5 to MySQL 5.6 using homebrew on our Macs to test locally before upgrading our servers. Since this upgrade, we all have been experiencing intermittent MySQL errors when running our…
Julie
  • 1,941
  • 3
  • 17
  • 30
49
votes
8 answers

ERROR: Failed to build gem native extension (mysql2 on rails 3.2.3)

I'm trying to install the mysql2 gem with Rails 3.2.3 and it's failing: ★ bundle install Fetching gem metadata from https://rubygems.org/......... Using rake (0.9.2.2) Using i18n (0.6.0) Using multi_json (1.2.0) Using activesupport (3.2.3)…
Ryan Arneson
  • 1,323
  • 3
  • 14
  • 25
44
votes
3 answers

Creating tables and problems with primary key in Rails

When I try to run the following code in Rails using Mysql2 as database manager: rake db:migrate I obtain the following error: rake aborted! "Mysql2::Error: All parts of a PRIMARY KEY must be NOT NULL:" Why do I get this error, if the primary key…
Hedley Quintana
  • 471
  • 1
  • 4
  • 5
42
votes
16 answers

Please install mysql adapter 'gem install activerecord-mysql-adapter'

I'm having trouble finding a solution to this problem. I'm getting the error: Please install the mysql adapter: 'gem install activerecord-mysql-adapter' /Users/…
Andy
  • 693
  • 2
  • 7
  • 8
39
votes
7 answers

mysql2 gem fails to compile with MySQL 5.6.12 on OS X with Homebrew

I updated all the packages I installed with Homebrew. MySQL got upgraded to 5.6.12 (from 5.5.27 or so): $ mysql --version mysql Ver 14.14 Distrib 5.6.12, for osx10.8 (x86_64) using EditLine wrapper and now the mysql2 gem doesn't compile…
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
38
votes
9 answers

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

I'm getting the following error when I start rails server: $ rails server /Users/ssmith/.rvm/gems/ruby-1.9.2-p0/gems/mysql2-0.2.6/lib/mysql2.rb:7:in `require': …
Scott
  • 1,034
  • 1
  • 9
  • 19
35
votes
18 answers

Ruby MYSQL2 gem installation on windows 7

I'm trying to installing the mysql2 gem on windows 7 I downloaded the connector from the mysql site and placed the libmysql.dll in ruby200\bin then do gem install mysql2 These are the results am I being dim here? Temporarily enhancing PATH to…
Mrk Fldig
  • 4,244
  • 5
  • 33
  • 64
1
2 3
60 61