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

Python Using PythonAnywhere’s MySQL

James J. McCombie
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
James J. McCombie
Python Web Development Techdegree Graduate 21,199 Points

jango.db.utils.OperationalError: (1045, "Access denied for user '<user>'@'10.0.0.39' (using password: YES)")

Hello,

when trying to run migrations I see this error

following the python anywhere tutorial, on the bit concerning using mysql

has anyone seen this, solved this?

James J. McCombie
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
James J. McCombie
Python Web Development Techdegree Graduate 21,199 Points

This is some help text i found on python anywhere.com...

When trying to get data in mysql, you may see an error a little like this:

Error Code: 1045 Access denied for user 'myusername'@'%' (using password: YES) The newer versions of mysql client block load data by default. You need to pass it in as a command line switch. If you open up a Bash console you can connect the the mysql database manually like so:

mysql -h myusername.mysql.pythonanywhere-services.com -u myusername 'myusername$default' -p --local-infile=1 "--local-infile=1" enables the load data command. You will be prompted for your password.

has anyone else been down this road before?

1 Answer

Vittorio Somaschini
Vittorio Somaschini
33,371 Points

Hello James.

I have little to no experience with python anywhere, but: Is this migration the initial one for django? Because to me it looks like the user that you have in the settings.py for the project has NOT been granted the priviledge to write the database.

Obviously this could be the case if this is the first ever migration you run for the project, otherwise it must be something else. Have you done the procedure to grant the privileges to that specific user? Something like this: http://stackoverflow.com/questions/2443419/django-mysql-1045-access-denied-for-user

Also, this page could be useful (or whatever version of mysql you are using): https://dev.mysql.com/doc/refman/5.7/en/problems-connecting.html

Let me know.

Vitto

James J. McCombie
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
James J. McCombie
Python Web Development Techdegree Graduate 21,199 Points

Thanks for the help Vittorio, I had solved the problem later the same evening as my post. I deleted everything and started over, and everything went fine (except for an issue with default values - I had heard warnings about this concerning using sqlite for development and mysql or equivalent in deployment, but that was fairly easy to solve). I don't know why it worked fine the second time around, cannot for the life of me find anything I done differently the first vs the second time, it's a mystery, so cannot learn anything from the problem...