Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Laura Cressman
Laura Cressman
12,548 Points

Rake db:create error!

Hi friends, I am trying to create the database using MySQL for the Migration video in ActiveRecord basics. However, I keep getting this nasty error! Any advice would be appreciated, thanks!

Smile more:) Laura

lauras-mbp:biller lauracressman$ rake db:create
rake aborted!
LoadError: dlopen(/Users/lauracressman/.rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-13/2.1.0-static/mysql2-0.3.16/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib
  Referenced from: /Users/lauracressman/.rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-13/2.1.0-static/mysql2-0.3.16/mysql2/mysql2.bundle
  Reason: image not found - /Users/lauracressman/.rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-13/2.1.0-static/mysql2-0.3.16/mysql2/mysql2.bundle
/Users/lauracressman/.rvm/gems/ruby-2.1.2/gems/mysql2-0.3.16/lib/mysql2.rb:8:in `require'
/Users/lauracressman/.rvm/gems/ruby-2.1.2/gems/mysql2-0.3.16/lib/mysql2.rb:8:in `<top (required)>'
/Users/lauracressman/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in `require'
/Users/lauracressman/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
/Users/lauracressman/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in `each'
/Users/lauracressman/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in `block in require'
/Users/lauracressman/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:in `each'
/Users/lauracressman/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:in `require'
/Users/lauracressman/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler.rb:132:in `require'
/Users/lauracressman/Desktop/Thinkful/biller/config/application.rb:7:in `<top (required)>'
/Users/lauracressman/Desktop/Thinkful/biller/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)

2 Answers

J Scott Erickson
J Scott Erickson
11,883 Points

I dealt with the same error the other day --

in your terminal type:

  sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
Mil Reyes
Mil Reyes
11,750 Points

Thanks J Scott Erickson! This is very helpful!

kabir k
kabir k
Courses Plus Student 18,036 Points

I did that but I got the following at the bottom of my error,

Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "pool"=>5, "username"=>"root", "password"=>nil, "socket"=>"/tmp/mysql.sock", "database"=>"biller_test"} rake aborted! Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded. Add gem 'mysql2' to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).

Gem::LoadError: can't activate mysql2 (~> 0.3.13), already activated mysql2-0.4.1. Make sure all dependencies are added to Gemfile.

Tasks: TOP => db:create (See full trace by running task with --trace)

J Scott Erickson
J Scott Erickson
11,883 Points

@kabir im thinking based on your error that you have either conflicting gem versions, or conflicting MySQL installs. I've started using brew to manage my installs ( and I've switched to Postgres long since this post ), you should ensure your gem version and MySQL version are both the appropriate versions.