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 ActiveRecord Basics Migrations and Relationships Migrations

Hossam Khalifa
Hossam Khalifa
17,200 Points

rake db:create fails

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).

although: gem 'mysql2' , '>=0.4' in Gemfile

3 Answers

Filip Vanderstappen
Filip Vanderstappen
3,877 Points

You have to specify a version lower than 0.4 for mysql2. It's a bug in rails for rails 4.x (https://github.com/rails/rails/issues/21544)

Use the following in your Gemfile:

gem 'mysql2', '~> 0.3.18'
Izabella Konstanciak
Izabella Konstanciak
10,173 Points

I had the same problem. I did as you told @Filip and then this appeared:

Could not find gem 'mysql2 (~> 0.3.18) ruby' in any of the gem sources listed in your Gemfile or available on this machine. Run `bundle install` to install missing gems.

So I used:

bundle install

then once again:

rake db:migrate

and it worked.

Max Hirsh
Max Hirsh
16,773 Points

Yeah, this is what worked for me. It sounds like this is a bug that they are working out for the next version of rails.

Kevin Korte
Kevin Korte
28,149 Points

delete the &#13 from the end of the url and reload. the forum is doing that to all links, page should load with those three characters removed.

if you are using OS 11, this could be a help https://forums.developer.apple.com/thread/7935

If you can actually read that link and understand it, it would be helpful. Alas, I cannot, so the link is not. Any dummed down help from that link would be appreciated as this course is no longer viable from this web site.