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

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

Access Denied

I receive an access denied message when I try to create a remote connection for user1. What should I do?

So, I was also unable to connect with user1 via localhost or its equivalent 127.0.0.1, and was able to fix the problem two different ways:

  1. Not changing Andrew's mysql statemant from the video at all, I was able to use my local IP address (ie 192.168.2.4) in Server Connection settings and use that to connect to the treehouse_moive_db.

To find you local IP address: On a Mac, go to System Preferences, click Network, and look for under "Ethernet" look for "IP Address" or under "Wi-Fi" and look for "Wi-Fi is connected to X and has the IP address of X.X.X.X". On a Windows PC, click the start button, click Run or click in the search box, type in cmd, hit Enter, type in "ipconfig", hit Enter, and look for IP Address or "IPv4 Address" for X.X.X.X (i.e. 10.1.42.2).

  1. Because I often change networks and my local IP address changes, I prefer this second way that lets you leave the IP address as 127.0.0.1 (which works even when I'm offline). To do this I follow the link that iainfriend mentioned: https://teamtreehouse.com/forum/cant-connect-user1-localhost-to-treehousemoviedb.

This has you modify Andrew's mysql statemant from the video changing user1@'%' to to user1@127.0.0.1. So, the whole mysql statemant looks like this:

GRANT SELECT ON treehouse_movie_db.* TO user1@127.0.0.1 IDENTIFIED BY 'password';

Even though I had already ran the GRANT SELECT statement, I ran the above statement again, and then ran the "FLUSH PRIVILEGES;" statement, and then I was able to connect using 127.0.0.1.

1 Answer

You should create user admin in your mysql. In terminal, you can type

<p>create user 'UserName'@'localhost' identified with mysql_native_password by 'yourPwd';</p>

Then you can create new connection in your workbench. This problem also confused me several hours. Hope I can help you.