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 trialRobert Mews
11,540 PointsError Code: 1044.
I'm using a hosting service for development and deployment (just not a fan of local hosting). I'm getting the following error which I think is related to admin permissions. Is anyone knowledgable on how to fix this?
Error Code: 1044. Access denied for user 'cl10-treehouse'@'%' to database 'treehouse_movie_db'
2 Answers
Jose Soto
23,407 PointsYou either do not have the user created or the user has not been granted privileges on the database.
Check to see if the user is created. Login to mysql using your root user and password. Run this from your SSH console.
> mysql --user=root --password
> ENTER PASSWORD:
mysql> USE mysql;
mysql> SELECT user, host FROM user;
+----------------+-----------------------+
| user | host |
+----------------+-----------------------+
| cl10-treehouse | % |
| root | localhost |
+----------------+-----------------------+
If you do not see the 'cl10-treehouse' with the '%' host, then you need to create it:
mysql> CREATE USER 'cl10-treehouse'@'%' IDENTIFIED BY 'reallyGoodPassword1';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON treehouse_movie_db.* TO 'cl10-treehouse'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
Now that the user is created and granted privileges on the database, your app should work.
Geoff Parsons
11,679 PointsIt depends on what hosting platform you're on - many of them will require you to set user permissions through a web interface. If you have root access to the MySQL server you can give the cl10-treehouse
user permissions on the treehouse_movie_db
with the following command:
GRANT ALL ON treehouse_movie_db.* TO 'cl10-treehouse';
For more information on the GRANT syntax checkout the MySQL documentation.
EDIT: "You may have to use 'cl10-treehouse'@'%'
to allow the user to connect from external machines. A bit rusty on my GRANT syntax sadly.
Robert Mews
11,540 PointsRobert Mews
11,540 PointsThanks, but I'm not sure what you mean by login to the root of MySQL - I thought that's what I did when I connected to the database through Workbench or phpMyAdmin? Under my CPanel, I create separate instances of MySQL databases and I can access those databases using either the phpMyAdmin or Workbench tools. Also can SSH commands not be run from phpAdmin or Workbench?
I wish Treehouse would have gone in-depth about how databases are configured and such rather than jump straight into running queries. It makes it hard for most to learn when everyone has different configurations.
Jose Soto
23,407 PointsJose Soto
23,407 PointsRobert, working with different configurations is the life of a developer. You can create users and set privileges using phpmyadmin. There is a great walkthrough here.
Robert Mews
11,540 PointsRobert Mews
11,540 PointsJose, thanks again. It seems phpMyAdmin isn't configured to allow those administration rights. This is what I'm seeing in phpMyAdmin:
And what I'm seeing in Workbench:
Jose Soto
23,407 PointsJose Soto
23,407 PointsYou're logging in as the 'cl10-treehouse' user. You will need to log in as 'root' in order to run these steps. If you don't know what your root password is, you may need to hit up your hosting provider's customer service to find out how to get root access.
Robert Mews
11,540 PointsRobert Mews
11,540 PointsJose, aha that's it! I didn't realize that I was actually creating separate databases and users with my current server config. I figured that if I just use the current username that I've setup and remove the DROP & CREATE commands in the movie_db.sql script that I can successfully import all the movie table data!