Rails: mysql load error when starting rails server - mysql

I am trying to migrate my rails application from rails version 3 to rails version 4.I have install mysql2 gem in my rails application and trying to run a rails server but I am getting below error.
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/act
ive_support/dependencies.rb:228:in `require': cannot load such file -- mysql2/2.
0/mysql2 (LoadError)
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.0.0/lib/active_support/dependencies.rb:228:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11-
x86-mingw32/lib/mysql2/mysql2.rb:2:in `<top (required)>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.0.0/lib/active_support/dependencies.rb:228:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.0.0/lib/active_support/dependencies.rb:228:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11-
x86-mingw32/lib/mysql2.rb:9:in `<top (required)>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:76:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:72:in `each'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:72:in `block in require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:61:in `each'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:61:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/
lib/bundler.rb:133:in `require'
from E:/JCI-stable-final-Version-7-AoneSms/onspot-rails4.0.0/config/appl
ication.rb:12:in `<top (required)>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0
/lib/rails/commands.rb:76:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0
/lib/rails/commands.rb:76:in `block in <top (required)>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0
/lib/rails/commands.rb:73:in `tap'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0
/lib/rails/commands.rb:73:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Below is my gemfile
source 'http://rubygems.org'
gem 'gmaps4rails'
gem 'geocoder'
gem 'groupdate'
gem "chartkick"
gem "paperclip"
gem "easy_captcha"
gem "rails_email_validator"
gem "devise_security_extension"
gem "will_paginate"
gem "prawn-labels"
gem "rails-xmlrpc"
gem "rqrcode_png"
gem "rqrcode"
gem "blueprint-rails"
gem "mysql2" , "0.3.11"
gem "jeweler"
#gem "activesupport"
#gem "activerecord"
#gem "activerecord-import"
#gem "activerecord-mysql-adapter"
#gem "mysql"
gem "yaml_db"
gem "tabulous"
gem "thin"
gem 'rails', '4.0.0'
gem "rake"
gem 'jquery-ui-rails'
gem 'cancan'
gem 'rolify'
gem 'rails_admin'
gem 'fastercsv'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
#gem 'sqlite3'
gem "devise"
#gem "devise", "~> 1.5.3"
#gem "orm_adapter", "~> 0.0.3"
gem 'json'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 4.0.0'
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.3.0'
end
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'
#gem 'css-bootstrap-rails'
# To use debugger
# gem 'ruby-debug'
gem 'impressionist'
gem 'devise-encryptable'
gem "devise_invitable"
Please help.
Thanks

gem uninstall mysql2
Download last MySQL connector from
http://cdn.mysql.com/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip
Extract it to C:\connector-6.0.2
gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\connector-6.0.2\lib" --with-mysql-include="C:\connector-6.0.2\include" --with-mysql-dir="C:\connector-6.0.2"'
If after installing the gem, you get an error:
"The specified module could not be found.
C:/Devel/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11/lib/mysql2/mysql2.so"
Then copy "libmysql.dll" to Ruby's bin folder.
If still you are unable to fix this issue, have a look at this article:
http://www.codeproject.com/Tips/798700/Install-Rails-and-MySQL-Server-on-Windows
Give a try, above trick might help.
But truly, try moving to linux machine. Windows is never recommended for rails development.

Related

undefined method `each' for "MySQL. Versions 5.0+ are recommended.":String in rails

cloned the application from my friend I am getting this error, but in his machine working fine(same os), and deleted the database and trying to recreate but same issue.
mysql version: 5.7.19-0ubuntu0.16.04.1
my database.yml
default: &default
adapter: mysql2
encoding: utf8
pool: 5
username: root
password: password
socket: /var/run/mysqld/mysqld.sock
development:
<<: *default
database: timeline_sheet
test:
<<: *default
database: timeline_sheet_test
here is my gem file
Gemfile
source 'https://rubygems.org'
gem 'rails', '4.2.7'
gem 'mysql2', '>= 0.3.13', '< 0.5'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'simple_form'
gem 'jquery-ui-rails', '~> 4.2.1'
gem 'bootstrap-datepicker-rails', '~> 1.6', '>= 1.6.1.1'
gem 'carrierwave'
gem 'prawn'
gem 'pdfkit', '0.5.0'
gem 'wkhtmltopdf-binary'
gem 'passenger', '~> 5.0', '>= 5.0.30'
gem 'simple_format'
gem 'webrick', '~> 1.3.1'
group :development, :test do
gem 'byebug'
end
group :development do
gem 'web-console', '~> 2.0'
gem 'spring'
end
application trace:
This error occurred while loading the following files:
active_record/base
Framework trace:
activerecord (4.2.7) lib/active_record/connection_adapters/connection_specification.rb:150:in `resolve_all'
activerecord (4.2.7) lib/active_record/connection_handling.rb:69:in `resolve'
activerecord (4.2.7) lib/active_record/core.rb:46:in `configurations='
activerecord (4.2.7) lib/active_record/railtie.rb:117:in `block (2 levels) in <class:Railtie>'
activesupport (4.2.7) lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
activesupport (4.2.7) lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
activesupport (4.2.7) lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
activesupport (4.2.7) lib/active_support/lazy_load_hooks.rb:44:in `each'
activesupport (4.2.7) lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
activerecord (4.2.7) lib/active_record/base.rb:315:in `<module:ActiveRecord>'
activerecord (4.2.7) lib/active_record/base.rb:26:in `<top (required)>'
activesupport (4.2.7) lib/active_support/dependencies.rb:274:in `require'
activesupport (4.2.7) lib/active_support/dependencies.rb:274:in `block in require'
activesupport (4.2.7) lib/active_support/dependencies.rb:240:in `load_dependency'
activesupport (4.2.7) lib/active_support/dependencies.rb:274:in `require'
activerecord (4.2.7) lib/active_record/migration.rb:383:in `connection'
activerecord (4.2.7) lib/active_record/migration.rb:370:in `call'

Rails Server causes error with Mysql2

I am running Rails 3.2 and Ruby 2.0 on a Windows 7 machine.
I finally got Mysql2 installed (at least I thought so). I can run "bundle install" with no problem, and mysql2 v.0.3.16 shows up in my gem bundle.
But when I run "gem install mysql2" it fails due to native extensions.
Now I am trying to run "rails s" to start my server, and I am getting more errors.
Stealth#STEALTH-PC ~/Documents/GitHub/flitti (tony-dev)
$ rails s
DL is deprecated, please use Fiddle
c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/mysql2-0.3.16/lib/mysql2.rb
:8:in `require': cannot load such file -- mysql2/mysql2 (LoadError)
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/mysql2-0.3.16/
lib/mysql2.rb:8:in `<top (required)>'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/
lib/bundler/runtime.rb:72:in `require'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/
lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/
lib/bundler/runtime.rb:70:in `each'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/
lib/bundler/runtime.rb:70:in `block in require'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/
lib/bundler/runtime.rb:59:in `each'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/
lib/bundler/runtime.rb:59:in `require'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/
lib/bundler.rb:132:in `require'
from c:/Users/Stealth/Documents/GitHub/flitti/config/application.rb:7:in
`<top (required)>'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-3.2.1
2/lib/rails/commands.rb:53:in `require'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-3.2.1
2/lib/rails/commands.rb:53:in `block in <top (required)>'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-3.2.1
2/lib/rails/commands.rb:50:in `tap'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-3.2.1
2/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
My Gemfile looks like this
source 'https://rubygems.org'
gem 'rails', '3.2.12'
gem 'foundation-rails'
gem 'mysql2'
gem 'merit'
gem 'devise'
gem 'paperclip', '3.4.0'
gem 'pry'
gem 'mailboxer'
gem 'simple_form'
gem 'thumbs_up'
gem 'jquery-rails'
gem 'faye'
gem 'private_pub', :git => 'git://github.com/ryanb/private_pub.git'
gem 'thin'
gem 'pjax_rails'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
group :development, :test do
gem 'rspec-rails'
gem 'factory_girl_rails'
end
group :test do
gem 'faker'
gem "capybara"
gem "guard-rspec"
gem "launchy"
end
How can I fix this so I can get my rails server working?
Native Extensions Error:
Stealth#STEALTH-PC /c
$ gem install mysql2 --platform=ruby -- '--with-mysql-dir="C:\mysql-connector-c
"'
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-mysql-dir="C:\mysql-connector-c"'
This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
c:/RailsInstaller/Ruby2.0.0/bin/ruby.exe extconf.rb --with-mysql-dir="C:\mys
ql-connector-c"
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Cannot find include dir(s) C:\mysql-connector-c/include
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=c:/RailsInstaller/Ruby2.0.0/bin/ruby
--with-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/
--with-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
Gem files will remain installed in c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0
.0/gems/mysql2-0.3.16 for inspection.
Results logged to c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/mysql2-0.
3.16/ext/mysql2/gem_make.out
Looks like a standard mingw32 issue with mysql2
--
The problem is that since Windows does not come with MYSQL already installed, you've got to install it from scratch. It seems you're privvy to this already, but because there's a new release of mysql2, you've got to update your C-Connector headers
We've written a tutorial on how to do this here
--
Fix
I would do this:
gem uninstall mysql2
Download the latest 32-bit version of mysql c-connector
Save the zip file & unpack it to a directory with no spaces
Once on your system, type this into cmd: gem install mysql2 —platform=ruby — ‘—with-mysql-dir=”C:\mysql-connector-path”’
Finally, copy libmysql.dll from your mysql/bin directory to your ruby/bin directory
Remove the mysql c-connector files
This should install it for you so you can use it without issue
First do:
gem uninstall mysql2
Then do:
Bundle install
It happened when I upgraded from ubuntu 14.04 to 16.04.
I did the above 2 steps and it corrected.

Mysql2 and Rails on Windows

So. I'm trying to develop a rails app, and I'm trying to do so in Windows 7. Here's what I've done:
Installed Ruby 1.9.3 using rubyinstaller
gem update
gem install rails
gem update
rails new
modified the gemfile, replace sqlite3 with mysql2
modified database.yml correctly
bundle install
gem update
Added mysql to my path
Added a hardlink to the libmysql c connector in the ruby bin
Everything works so far, except when I do rake db:create:all, which results in:
rake aborted!
126: The specified module could not be found. - C:/Ruby193/lib/ruby/gems/1.9.1
/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/1.9/mysql2.so
C:/Users/username/Documents/workspace/appname/config/application.rb:7:in `<top (
required)>'
C:/Users/username/Documents/workspace/appname/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)
wtf?
UPDATE:
Full trace, by request:
rake aborted!
126: The specified module could not be found. - C:/Ruby193/lib/ruby/gems/1.9.1
/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/1.9/mysql2.so
C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.
rb:2:in `require'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.
rb:2:in `<top (required)>'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2.rb:9:in
`require'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2.rb:9:in
`<top (required)>'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `
require'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `
block (2 levels) in require'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `
each'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `
block in require'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `
each'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `
require'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler.rb:128:in `require
'
C:/Users/mschultz/Documents/workspace/recruit/config/application.rb:7:in `<top (
required)>'
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
C:/Users/mschultz/Documents/workspace/recruit/Rakefile:5:in `<top (required)>'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_module.rb:25:in `l
oad'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_module.rb:25:in `l
oad_rakefile'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:583:in `
raw_load_rakefile'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:89:in `b
lock in load_rakefile'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:160:in `
standard_exception_handling'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:88:in `l
oad_rakefile'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:72:in `b
lock in run'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:160:in `
standard_exception_handling'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:70:in `r
un'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/bin/rake:33:in `<top (required)>
'
C:/Ruby193/bin/rake:23:in `load'
C:/Ruby193/bin/rake:23:in `<main>'
gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.9'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2'
gem 'json'
# 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 '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 'ruby-debug'
Im using railsinstaller
solution: you have to add libmysql.dll to Ruby bin, btw its hint from bundle installator if you are creating app with --database=mysql parameter
If I may recommend.
http://railsinstaller.org/
is the easiest way to get rails installed. Just make sure it matches the correct system software.
However, I don't think it's your install. I think it's that you changed your DB. Firstly, I'd recommend using PG, I think it's a lot better than sql2 or sql3.
However, given you want sql2 for some reason, I think your modified database.yml is off. You stated it was correct, but you may want to double check it.
I'm not an expert, but maybe something was helpful here. Otherwise, good luck!

Installing mysql2 gem on mac with RVM is real pain

Step 1:--
rails s/usr/local/rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.2/lib/mysql2.rb:8:in `require': dlopen(/usr/local/rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.16.dylib (LoadError)
Referenced from: /usr/local/rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
Reason: image not found - /usr/local/rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.2/lib/mysql2.rb:8:in `<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `each'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `block in require'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `each'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `require'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler.rb:120:in `require'
from /Users/mohit/projects/lbs_admin/config/application.rb:7:in `<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/commands.rb:28:in `require'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/commands.rb:28:in `block in <top (required)>'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/commands.rb:27:in `tap'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
STEP 2:--
sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql-5.5.9-osx10.6-x86_64/lib/libmysqlclient.16.dylib /usr/local/rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
Result:--
rails sWARNING: 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
=> Booting WEBrick
=> Rails 3.0.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:71:in `rescue in establish_connection': Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (no such file to load -- active_record/connection_adapters/mysql2_adapter) (RuntimeError)
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:68:in `establish_connection'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:60:in `establish_connection'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:in `establish_connection'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.3/lib/active_record/railtie.rb:59:in `block (2 levels) in <class:Railtie>'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:42:in `each'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.3/lib/active_record/base.rb:1891:in `<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/will_paginate-3.0.pre2/lib/will_paginate/finders/active_record.rb:31:in `enable!'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/will_paginate-3.0.pre2/lib/will_paginate/railtie.rb:9:in `block in <class:Railtie>'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `instance_exec'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `run'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/initializable.rb:50:in `block in run_initializers'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `each'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `run_initializers'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/application.rb:134:in `initialize!'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing'
from /Users/mohit/projects/lbs_admin/config/environment.rb:5:in `<top (required)>'
from /Users/mohit/projects/lbs_admin/config.ru:3:in `require'
from /Users/mohit/projects/lbs_admin/config.ru:3:in `block in <main>'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.2/lib/rack/builder.rb:46:in `instance_eval'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.2/lib/rack/builder.rb:46:in `initialize'
from /Users/mohit/projects/lbs_admin/config.ru:1:in `new'
from /Users/mohit/projects/lbs_admin/config.ru:1:in `<main>'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.2/lib/rack/builder.rb:35:in `eval'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.2/lib/rack/builder.rb:35:in `parse_file'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.2/lib/rack/server.rb:162:in `app'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.2/lib/rack/server.rb:248:in `wrapped_app'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.2/lib/rack/server.rb:213:in `start'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/commands/server.rb:65:in `start'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/commands.rb:30:in `block in <top (required)>'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/commands.rb:27:in `tap'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.3/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Step 3:--
sudo gem uninstall mysql2
sudo env ARCHFLAGS="-arch i386" gem install mysql2 -- --with-mysql-config=/usr/local/mysql-5.5.9-osx10.6-x86_64/bin/mysql_config
Current status:--
ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0]
rails -v
Rails 3.0.3
gem list
*** LOCAL GEMS ***
abstract (1.0.0)
actionmailer (3.0.7, 3.0.3)
actionpack (3.0.7, 3.0.3)
activemodel (3.0.7, 3.0.3)
activerecord (3.0.7, 3.0.3)
activeresource (3.0.7, 3.0.3)
activesupport (3.0.7, 3.0.3)
annotate-models (1.0.4)
arel (2.0.9)
builder (2.1.2)
bundler (1.0.12)
erubis (2.6.6)
i18n (0.5.0)
mail (2.2.19)
mime-types (1.16)
mysql2 (0.3.2)
polyglot (0.3.1)
rack (1.2.2)
rack-mount (0.6.14)
rack-test (0.5.7)
rails (3.0.7, 3.0.3)
railties (3.0.7, 3.0.3)
rake (0.8.7)
thor (0.14.6)
treetop (1.4.9)
tzinfo (0.3.27)
web-app-theme (0.6.3)
will_paginate (3.0.pre2)
locate mysql_config
/usr/local/mysql-5.5.9-osx10.6-x86_64/bin/mysql_config
/usr/local/mysql-5.5.9-osx10.6-x86_64/man/man1/mysql_config.1
bundle show mysql2
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.2
locate libmysqlclient.16.dylib
/usr/local/mysql-5.5.9-osx10.6-x86_64/lib/libmysqlclient.16.dylib
How can I proceed?
I have the sam problem. What I did is doing;
gem install --version '0.2.7' mysql2
Then on your Rails's GemFile. Should look like this.
gem 'mysql2', '0.2.7'
Then try again. Hope it help.
Your stacktrace after Step 2 told you what to do:
Please install the mysql2 adapter: gem install activerecord-mysql2-adapter
Update
Also, upgrade your Rails to 3.0.7 - there are a number of security holes (and bugs) in 3.0.3.
Update
Looks like that error message from Rails is wrong, it should have read:
Please use the 0.2.x releases if you plan on using it in Rails <= 3.1
Ie. for anything less than 3.1 you need to pin mysql2 to the 0.2 release, and not allow it to use 0.3. To do this, change your mysql2 line in your Gemfile to this:
gem "mysql2", "~> 0.2"
Then re-run bundle install
rails sWARNING: 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
MySql version '0.2.7' solved my issue.
gem 'mysql2', '0.2.7'
Try this (but I cannot guarantee anything)
Check this post about how to
remove MySQL 5.5.
install MySQL 5.1 (I think I downloaded the 32bit DMG version)
Follow this post to create the GEM.
Hopefully it will work after this. I'll cross my fingers for you.
The above problem occurs presently on EngineYard App Cloud with Ruby 1.9.2 and Rails 3.0.3. Using mysql 2.8.1 barfs b/c EY sets mysql2 adapter. Using mysql2 0.3.2 barfs. So I was seriously stumped. Props to Richard Soutar's answer. It worked.

rails mysql adapter error

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'
when I specify either ruby-mysql or mysql2 in my Gemfile. This has only happened since I've upgraded to Rails 3.1.0-rc1. I'm running OSX 10.6, Ruby 1.9.2.
cody$ rails c
/Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract/connection_specification.rb:71:in `rescue in establish_connection': Please install the mysql adapter: `gem install activerecord-mysql-adapter` (mysql is not part of the bundle. Add it to Gemfile.) (RuntimeError)
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract/connection_specification.rb:68:in `establish_connection'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract/connection_specification.rb:60:in `establish_connection'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:in `establish_connection'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/railtie.rb:69:in `block (2 levels) in <class:Railtie>'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.0.rc1/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.0.rc1/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.0.rc1/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.0.rc1/lib/active_support/lazy_load_hooks.rb:42:in `each'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.0.rc1/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/base.rb:2135:in `<top (required)>'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/railtie.rb:34:in `block in <class:Railtie>'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/railtie.rb:177:in `call'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/railtie.rb:177:in `block in load_console'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/railtie.rb:177:in `each'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/railtie.rb:177:in `load_console'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/application.rb:115:in `block in load_console'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/application/railties.rb:8:in `each'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/application/railties.rb:8:in `all'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/application.rb:115:in `load_console'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/commands/console.rb:26:in `start'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/commands/console.rb:8:in `start'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Here is the gem env output
cody$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.6.2
- RUBY VERSION: 1.9.2 (2011-02-18 patchlevel 180) [x86_64-darwin10.7.3]
- INSTALLATION DIRECTORY: /Users/cody/.rvm/gems/ruby-1.9.2-p180
- RUBY EXECUTABLE: /Users/cody/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
- EXECUTABLE DIRECTORY: /Users/cody/.rvm/gems/ruby-1.9.2-p180/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-10
- GEM PATHS:
- /Users/cody/.rvm/gems/ruby-1.9.2-p180
- /Users/cody/.rvm/gems/ruby-1.9.2-p180#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://gems.rubyforge.org/", "http://gems.github.com"]
- REMOTE SOURCES:
- http://gems.rubyforge.org/
- http://gems.github.com
You'll have to change your config/database.yml to use the mysql2 adapter instead of mysql.
So replace:
adapter: mysql
With:
adapter: mysql2
I had to enforce the use of mysql2 gem version 0.2.7 and while trying to upgrade my rails 3.0.7 app to 3.1.0.rc1, I also noticed ,that you'll need the following new gems in your Gemfile, too:
gem 'mysql2', '< 0.3' # as stated above
# Asset template engines
gem 'json'
gem 'sass'
gem 'coffee-script'
gem 'uglifier'
# other required things for rails 3.1
gem 'jquery-rails'
gem 'mustang' # this is ONE execjs backend of many, and the only one that worked for me.
Tell me if that worked for you.
Fixed the problem by updating the gemfile for my app to identify mysql2 as part of the bundle.
To do this, navigate to the root of your app, run open gemfile
Add the line gem 'mysql2', '< 0.3.7' directly below the gem line for rails.
While in terminal at the root of your app, run bundle install
Run bundle show mysql2 to verify the bundle worked. You should be good to go with the adapter now.
My environment is Rails 3.1, MySql 5.5, Ruby 1.9.2.
I created a Rails project on windows and moved it to a machine running Fedora. I solved this problem by renaming the "Gemfile.lock" to "old_Gemfile.lock". Of course, you must still specify the adapter as 'mysql2' and include the appropriate gem in your gemfile.