Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby ActiveRecord Basics Migrations and Relationships Migrations

Michael Hulet
Michael Hulet
47,842 Points

Root Password for MySQL on the Treehouse VM?

So I'm trying to take the ActiveRecord Basics course using the Treehouse VM used in earlier ruby videos, and when it comes to rake db:create after setting the projects database to be MySQL (when running rails new), I get an error saying: "Access denied for user 'root'@'localhost' (using password: NO)Please provide the root password for your MySQL installation". My question is, what is that root password?

5 Answers

I just ran into this same issue. I followed the advice on this thread to fix the problem. Here are the steps I took (YMMV):

  1. For me, the treehouse VM password for the mysql root account was "treehouse"
  2. Open mysql CLI using mysql -u root -p and specifying "treehouse" as the password.
  3. Run the following statements: UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; FLUSH PRIVILEGES;
  4. In your rails project, open config/database.yml and specify your new password in dev, test and production.
  5. Run rake db:create again.
Alvin Shern
Alvin Shern
3,421 Points

Thanks! Solved my problem.

Alvin Shern
Alvin Shern
3,421 Points

Thanks! Solved my problem.

Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

Hey Michael Hulet there should be no root mysql password. Which treehouse vm are you using? That will help us troubleshoot the issue.

Michael Hulet
Michael Hulet
47,842 Points

After running vagrant ssh to log into it, it says that it's running Ubuntu 12.04.3 LTS (GNU/Linux 3.8.0-33-generic i686)

Michael Hulet
Michael Hulet
47,842 Points

Does that information help any, Jason Seifer ?

Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

Michael Hulet Yep! That VM shouldn't have a mysql root password set. Perhaps one was set accidentally or by a random program? Perhaps try downloading the VM again.

Michael Hulet
Michael Hulet
47,842 Points

I tried totally reinstalling the Treehouse VM (the one for Build a Todo List Application with Rails 4), and the same thing happens. Do you think it might have something to do with the fact that I have MySQL Workbench installed on the host machine from the Database Foundations course earlier in the Rails track?

Michael Hulet
Michael Hulet
47,842 Points

I just took super drastic measure and installed OS X fresh on an external drive, booted my Mac to that, installed Vagrant, VirtualBox, and the described Treehouse VM, and I still got the same error, so I don't think it's my machine

Michael Hulet
Michael Hulet
47,842 Points

So I ended up spending the past couple weeks scouring the internet for possible answers, and I ended up getting it working locally on my Mac by running brew install mysql, then starting the MySQL server with mysql.server start. I almost got it working on Ubuntu 14.04 on my ChromeBook (running ChrUbuntu) by installing a few developer libraries with APT, but it says it's just missing a JavaScript Runtime Environment, and I'm honestly too lazy to fix that, since I just got it working on my Mac

Jon Thomas
Jon Thomas
8,916 Points

I'm getting this on the treehouse vm as well.

Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "database"=>"biller_test", "pool"=>5, "username"=>"root", "password"=>nil, "socket"=>"/var/run/mysqld/mysqld.sock"}
Jon Thomas
Jon Thomas
8,916 Points

It looks like using "treehouse" as the password worked.