Andrea Rocca
Andrea Rocca

Reputation: 11

Please install mysql2 adapter

I'm new of rails, and i have this big problem. I'm running rails 3.2.9 and Ruby 1.9.3, I did a porting of a rails app from linux to windows, but in windows i'm having a lot of problems with mysql2 gem. I installed mysql2 gem yesterday and than i tried to run rake db:migrate but i have this output:

rake aborted!
Please install the mysql2 adapter: gem install activerecord-mysql2-adapter (cannot load such file -- mysql2)
C:/Users/RoccaA/Desktop/project/config/environment.rb:5:in `'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

Then this is my Gemfile

gem 'rails', '3.2.9'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
#gem 'sqlite3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
#  gem 'coffee-rails', '~> 3.2.1'
  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby
 # gem 'uglifier', '>= 1.0.3'
end
 gem 'coffee-rails', '~> 3.2.1'
 gem 'uglifier', '>= 1.0.3'
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
# this gems needs for auth
gem 'cancan'
gem 'devise'
gem 'rolify'
gem 'execjs'
gem 'therubyracer', :platform => :ruby
gem 'populator'
gem 'faker'
gem 'paperclip'
gem 'simple_xlsx_writer'
gem 'roo'
gem 'mysql2', '0.3.11'
gem 'simple_xlsx_writer'
gem 'rake', '~> 10.0.4'
gem 'icalendar'

And this is my database.yml

development:

  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: emc
  pool: 5
  username: root
  password: root
  socket: /var/run/mysqld/mysqld.sock
testing:

  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: emc
  pool: 5
  username: root
  password: root
  socket: /var/run/mysqld/mysqld.sock
production:

  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: emc
  pool: 5
  username: root
  password: root
  socket: /var/run/mysqld/mysqld.sock

I tried to solve this problem in a lots of ways, i read that i have to use mysql2 version < 0.3 but with this version I have this output

WARNING: This version of mysql2 (0.2.18) isn't compatible with Rails 3.1 as the ActiveRecord adapter was pulled into Rails itself.
WARNING: Please use the 0.3.x (or greater) releases if you plan on using it in Rails >= 3.1.x
rake aborted!
undefined method `accept' for nil:NilClass
Tasks: TOP => db:migrate
(See full trace by running task with --trace)**

Hope someone can help me, thanks.

Upvotes: 0

Views: 2221

Answers (5)

Aaron Henderson
Aaron Henderson

Reputation: 1880

Good detailed steps here => http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/

Some key points are installing the right version of mysql, the dot net connector, and the gem. Also be sure to place the libmysql file in the correct place.

Upvotes: 0

shrikant1712
shrikant1712

Reputation: 4446

Forget about it.Insted of it use rails installer from http://www.railsinstaller.org/ it will automatically install mysql2 with ruby and rails with latest versions

Upvotes: 1

Lian
Lian

Reputation: 1629

gem "mysql2", "~> 0.3.11"

and then bundle install

Upvotes: 0

Lian
Lian

Reputation: 1629

Try this to you gemfile

instead of using:

gem 'mysql2', '0.3.11'

use this:

gem 'mysql2'

This is working for me.

And by the way you have duplicate gem

gem 'simple_xlsx_writer'

Upvotes: 1

Mindbreaker
Mindbreaker

Reputation: 1025

Installing Rails and the mysql2 gem in windows is not as easy as on other os. But i found a good answer to your question:

Unable to install MySQL2 gem on Windows 7

The best thing to do is, to install rails on windows with the rubyinstaller.

Upvotes: 0

Related Questions