Forums

Can't connect to DB

When running this code:

app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://svukelic:kokolo1991@svukelic.mysql.pythonanywhere-services.com:3306/svukelic$paceri'

db = SQLAlchemy(app)

def check_connection():

    try:

        db.session.execute('SELECT 1')  # Execute a simple query

        print("DB OK")

    except Exception as e:

        print(e)

I am getting following error message:

Access denied for user 'svukelic'@'10.0.0.149' (using password: YES)

What can be reason for this?

These are my settings:

Database host address:svukelic.mysql.pythonanywhere-services.com

Username:svukelic

Database name: svukelic$paceri

It sounds like you're using the wrong password; have you checked that it's the same as the one in the file .my.cnf in your home directory?