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

gerald blady
gerald blady
9,052 Points

rake db:create fails (can't seem to figure out based on other questions)

So when I run rake db:create it fails with the following error.

Could not find gem 'mysql2 (>= 0) ruby' in the gems available on this machine. Run bundle install to install missing gems.

I run bundle install to this error message:

An error occurred while installing mysql2 (0.3.17), and Bundler cannot continue. Make sure that gem install mysql2 -v '0.3.17' succeeds before bundling.

That fails as well.

Digging deeper I ran this in terminal.

mysql -bash: mysql: command not found

So I looked at other questions on this task to no avail.

I have mysql installed as i did it with the last ruby course prior to this one.

Any help would be greatly appreciated on the matter. Let me know other screenshots / info I need to provide to move past this matter.

please help!!!

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Hey Gerald, first tell me what operating system you're on.

gerald blady
gerald blady
9,052 Points

OS X 10.9.5

and thanks for the swift reply

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Do you have mysql instead of sqlite in your Gemfile? How does your config/database.yml file look like?

6 Answers

gerald blady
gerald blady
9,052 Points

Just did this, and it seemed to work, as i see this among other gems in terminal.

Installing mysql2 0.3.17

so then i did the rake db:create to which this happened.

Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "pool"=>5, "username"=>"root", "password"=>nil, "host"=>"localhost", "database"=>"biller_development"}, {:charset=>"utf8", :collation=>"utf8_unicode_ci"} (If you set the charset manually, make sure you have a matching collation) Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "pool"=>5, "username"=>"root", "password"=>nil, "host"=>"localhost", "database"=>"biller_test"}, {:charset=>"utf8", :collation=>"utf8_unicode_ci"} (If you set the charset manually, make sure you have a matching collation)

Jeff Jacobson-Swartfager
Jeff Jacobson-Swartfager
15,419 Points

If you are using a ruby versioning system like rvm or rbenv, make sure that

  1. You are using the right ruby

    ruby -v
    

    or (for rvm)

    rvm list
    

    or (for rbenv)

    rbenv versions
    
  2. You are using the right gemset

    which gem
    

    or (for rvm)

    rvm gemset list
    

Since you are using bundler, you can also make sure you are using the right ruby and gemsets by declaring them in your Gemfile.

gerald blady
gerald blady
9,052 Points

mysql -v ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) Jerrys-MacBook-Pro:~ jerryblady$ mysql.server start Starting MySQL .... ERROR! The server quit without updating PID file (/usr/local/var/mysql/Jerrys-MacBook-Pro.local.pid

gerald blady
gerald blady
9,052 Points

Completely removed MySQL via brew, reinstalled via brew, still, no luck

Blake Baxendell
Blake Baxendell
16,344 Points

I am having the exact same issues, I removed, reinstalled. I also went through all the steps again. Hopefully some one at Treehouse can figure out this issue.

Blake Baxendell
Blake Baxendell
16,344 Points

Seems that there is nothing solving this issue?

Jeff Jacobson-Swartfager
Jeff Jacobson-Swartfager
15,419 Points

I'm thinking it has something to do with rbenv, but I haven't had the chance on a rbenv machine (all of mine are running rvm).

Blake Baxendell
Blake Baxendell
16,344 Points

I just moved on to another course. I may get back on this, hoping for an answer, but I will continue on with Ruby and just skip this lesson.