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 trialTrevin Cole
377 Pointsrake db: create doesn't work!
I'm on Windows and installed MySQL and workbench from the database tutorial. MySQL2 shows up fine in my database.yml file and my Gemfile. However, when I try and run the command from the tutorial for rake db:create this is what I get:
C:\Users\Trevin\cf>rake db:create
DL is deprecated, please use Fiddle
Specified 'mysql2' for database adapter, but the gem is not loaded. Add gem 'my
sql2'
to your Gemfile (and ensure its version is at the minimum required by Act
iveRecord).
Then this:
C:/Ruby21/lib/ruby/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/connecti
on_adapters/connection_specification.rb:177:in rescue in spec'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/connecti
on_adapters/connection_specification.rb:174:in
spec'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/connecti
on_handling.rb:50:in establish_connection'
C:in
establish_connection'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/tasks/my
sql_database_tasks.rb:15:in create'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/tasks/da
tabase_tasks.rb:93:in
create'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/tasks/da
tabase_tasks.rb:107:in block in create_current'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/tasks/da
tabase_tasks.rb:275:in
block in each_current_configuration'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/tasks/da
tabase_tasks.rb:274:in each'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/tasks/da
tabase_tasks.rb:274:in
each_current_configuration'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/tasks/da
tabase_tasks.rb:106:in create_current'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/railties
/databases.rake:17:in
block (2 levels) in <top (required)>'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:240:in call'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:240:in
block in
execute'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:235:in each'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:235:in
execute'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:179:in block in
invoke_with_call_chain'
C:/Ruby21/lib/ruby/2.1.0/monitor.rb:211:in
mon_synchronize'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:172:in invoke_w
ith_call_chain'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:165:in
invoke'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:150:in i
nvoke_task'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in
b
lock (2 levels) in top_level'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in e
ach'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in
b
lock in top_level'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:115:in r
un_with_threads'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:100:in
t
op_level'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:78:in bl
ock in run'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:176:in
s
tandard_exception_handling'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:75:in ru
n'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/bin/rake:33:in
<top (required)>'
C:/Ruby21/bin/rake:23:in load'
C:/Ruby21/bin/rake:23:in
<main>'
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "pool"=>5
, "username"=>"root", "password"=>nil, "host"=>"localhost", "database"=>"cf_deve
lopment"}
Specified 'mysql2' for database adapter, but the gem is not loaded. Add gem 'my
sql2'
to your Gemfile (and ensure its version is at the minimum required by Act
iveRecord).
C:/Ruby21/lib/ruby/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/connecti
on_adapters/connection_specification.rb:177:in rescue in spec'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/connecti
on_adapters/connection_specification.rb:174:in
spec'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/connecti
on_handling.rb:50:in establish_connection'
C:in
establish_connection'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/tasks/my
sql_database_tasks.rb:15:in create'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/tasks/da
tabase_tasks.rb:93:in
create'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/tasks/da
tabase_tasks.rb:107:in block in create_current'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/tasks/da
tabase_tasks.rb:275:in
block in each_current_configuration'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/tasks/da
tabase_tasks.rb:274:in each'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/tasks/da
tabase_tasks.rb:274:in
each_current_configuration'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/tasks/da
tabase_tasks.rb:106:in create_current'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/railties
/databases.rake:17:in
block (2 levels) in <top (required)>'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:240:in call'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:240:in
block in
execute'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:235:in each'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:235:in
execute'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:179:in block in
invoke_with_call_chain'
C:/Ruby21/lib/ruby/2.1.0/monitor.rb:211:in
mon_synchronize'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:172:in invoke_w
ith_call_chain'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:165:in
invoke'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:150:in i
nvoke_task'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in
b
lock (2 levels) in top_level'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in e
ach'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in
b
lock in top_level'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:115:in r
un_with_threads'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:100:in
t
op_level'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:78:in bl
ock in run'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:176:in
s
tandard_exception_handling'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:75:in ru
n'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rake-10.4.2/bin/rake:33:in
<top (required)>'
C:/Ruby21/bin/rake:23:in load'
C:/Ruby21/bin/rake:23:in
<main>'
And finally, this message:
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "pool"=>5
, "username"=>"root", "password"=>nil, "host"=>"localhost", "database"=>"cf_test
"}
rake aborted!
Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not load
ed. 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-x86-mingw32. Make sure all dependencies are added to Gemfile.
Tasks: TOP => db:create (See full trace by running task with --trace)
What can I do to create a database and remove this error?
Please HELP! Been stuck for hours and tried every solution available from Google, StackOverflow, and TeamTreehouse.
1 Answer
Seth Reece
32,867 PointsHi Trevin,
There have been some issues with Rails 4.1+ combined with mysql2 0.4.0. Try specifying v 0.3.18 in your gem file. e.g.
gem 'mysql2', '~> 0.3.18'
Trevin Cole
377 PointsAfter digging through a mountain of recommendations I tried that and it worked! Thanks for the response! In addition, I was not able to use mysql -uroot either; however, I found that mysql, when installed onto windows from their site, has its own "command line" style interface(just in case anyone else has that problem as well).
Trevin Cole
377 PointsTrevin Cole
377 PointsOh and I'm using "cf" instead of "biller" to clarify.