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!

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

Development Tools Database Foundations Securing and Maintaining a MySQL Database Setting up Multiple Users

Ron Chan
Ron Chan
10,987 Points

Error Code: 1044. Access denied for user '@localhost' to database 'treehouse_movie_db'

I could not run the sql script for treehouse_movie_db as before when using the new connection created at around 3:00 in this video called "Admin for Remote Connection" . I got the above error message in the action outputwhich prevented the database from being populated. I am not sure what is different about this connection that caused the error.

Looking through some of the forum threads for this video, someone suggested granting privileges to admin, but it isn't working either maybe because I am not doing it right. Anyone found a solution to this while working through this video?

Robert Mews
Robert Mews
11,540 Points

I'm receiving the same error. Is your MySQL instance on your local machine or hosting service? Mine is accessed using a hosting service as that's where I conduct development and deploy. I quite can't figure out how to change admin services either. Hoping someone a little more knowledgable can help us.

2 Answers

I solved this problem by using the permissions window:

  1. Go back to a login with root (the way we were working before this video).
  2. On the left pane, click on "Users and Privileges".
  3. In the list that appears, you should see the "user1" that we just created. Click on it.
  4. Click on the tab labeled "Schema Privileges". Here you'll probably see the problem with your privileges. For me, there was a wrong name for the database. I have no idea how that happened.
  5. I just hit the button for "Revoke All Privileges" to clean out the mistake.
  6. Click the "Add Entry" button.
  7. Choose the database we will be working on, treehouse_movie_db. Click OK.
  8. Now check the box labeled "SELECT".
  9. Click "Apply" in the bottom right corner.

That fixed it for me, and I was able to follow along with the rest of the video.

The solution on this page https://teamtreehouse.com/forum/cant-connect-user1-localhost-to-treehousemoviedb worked for me.

dim chan about 1 year ago okay, did use "to user1@''" instead of "to user1@'%'"..

Andreza Feu
Andreza Feu
Python Web Development Techdegree Student 15,148 Points

I tried this solution but it did not work for me. I'm getting the error:

Failed to connect to MySQL at with user1 Acess denied for user 'user1@localhost' (using password: YES)