Forums

Access denied for user 'shamseer' on MySQL database

Hi everyone,

I'm having trouble connecting my Django project to the MySQL database on PythonAnywhere. I'm a free-tier user.

Here are my database settings in settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'shamseer$meeting_project_db',
        'USER': 'shamseer',
        'PASSWORD': 'shoaiba',
        'HOST': 'shamseer.mysql.pythonanywhere-services.com',
        'PORT': '3306',
    }
}

When I try to run python manage.py migrate, I get the following error:

OperationalError: (1045, "Access denied for user 'shamseer'@'%' to database 'shamseer$meeting

I've tried connecting to the database from the Bash console using:

mysql -u shamseer -p -h shamseer.mysql.pythonanywhere-services.com shamseer$meeting_project_db

But I'm still getting access denied errors. When I run SHOW GRANTS FOR 'shamseer'@'shamseer.mysql.pythonanywhere-services.com'; I get:

ERROR 1141 (42000): There is no such grant defined for user 'shamseer' on host 'shamseer.mysql.pythonanywhere-services.com';,

Conclusion

By following these steps and providing detailed information, you'll be able to get assistance from the PythonAnywhere community or support team to resolve your database connection issues. If you need further assistance, feel free to ask!

[formatted by admin]

Have a look at this help page. To start debugging try the mysql command in a Bash console -- but mind that you need to put your database name in single quotes. Otherwise Bash will interpret the bit after "$" as a variable and will expand it to an empty string which will result in the error you get.