Forums

1045 mysql error using password: NO

Hi,

I have set up my Django settings file according to this page: https://www.pythonanywhere.com/wiki/UsingMySQL The database is password is pulled from an environment variable like so: DB_PASSWORD = os.getenv('DB_PWD') DATABASES = {... ... 'PASSWORD':DB_PASSWORD

The string in this environment variable is the same as that entered in the password field in the 'Databases' tab.

A few observations: 1. I can successfully run 'python manage.py syncdb'. 2. I can open a python shell and request an object list and be returned something empty (communication is happening) 3. From a bash shell, I can open a mysql shell like so: mysql -u <username> -h mysql.server -p

Then I type in the password on the 'Database' tab, and it will open the shell. 4. I cannot run any commands like 'flush privileges', 'grant...', or 'select from mysql.user' or 'use mysql'

When I press the large reload button in the 'Web' tab and open a new tab and navigate to the url, I get the following error:

(1045, "Access denied for user 'arkaeologic'@'ip-10-47-149-9.ec2.internal' (using password: NO)")

I do not know what to do. The error implies that the password is not being used and so no match for the user is found. I do not know how to tell django to use the password. Thanks in advance.

Do you set the env vars in your WSGI config file? You'll need to do this for them to be available to the WSGI handler.

what serenity said. web apps run on different servers from consoles. Although they have access to the same files, they don't have the same environment variables...

That worked. Thank you very much. In ..._wsgi.py I set:

os.environ['DB_PASSWORD'] = <password>

Then reloaded. It works.

Excellent, thanks for confirming!