2

I have tried 3 ways to access the database:

  1. [WORKS] from bash shell: ~$ mysql -u <username> -h mysql.server -p '<username>$<db_name>'
  2. [WORKS] ~$ python manage.py syncdb
  3. [DOES NOT WORK]
    • Syncdb
    • Reload app
    • Go to url

Error:

_mysql_exceptions.OperationalError: (1045, "Access denied for user '<username>'@'ip-10-186-190-7.ec2.internal' (using password: NO)")

Settings:

DATABASES = {
  'default': {
    'ENGINE': 'django.db.backends.mysql',
    'NAME': '<username>$<db_name>',
    'USER': '<username>',
    'PASSWORD': <password>,
    'HOST': 'mysql.server',
    'PORT': '3306',
  }
}

Pythonanywhere's wsgi module is loading the correct settings script. The database password has been set and checked in the 'Databases' tab.

I am using Django 1.7, Python 3.4, mysqlclient 1.3.4, inside a virtualenv.

Thanks for your help.

[Edit]:

The first error is actually:

AttributeError: 'SessionStore' object has no attribute '_session_cache'

I don't know if this is meaningful.

1 Answer 1

4

The problem was the lack of database connection, and not related specifically to the session backend. I was providing the password for the database though an os.environ variable. This has to be set in the python anywhere wsgi script:

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

All fixed.

Sign up to request clarification or add additional context in comments.

3 Comments

Haha. Yes. Thanks for spotting that. My mac thinks it knows best.
Thanks @arkaeologic for the tip on how to setup wsgi file. In my settings.py I'm grabbing all my database info from env. variables like so: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': environ['DB_NAME'], 'USER': environ['DB_USERNAME'], 'PASSWORD': environ['DB_PASSWORD'], 'HOST': environ['DB_HOST'], 'PORT': '', } }
This instructions also helped me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.