Forums

Access denied for user....

Im getting this error when tryin to connect to my mysql database on pythonanywhere. I am running a simple Flask application running Python 3.3. Would anybody have any idea as to why I am getting this error. I am new with regards to Python and deploying to pythonanywhere so apologies if my question is a bit vague.

What are the connection settings you're using? If you just post the code here (obviously putting something like XXXXXX on top of the password) then that would help us debug.

Ok, I have a class that I am using to connect to the my database. I am not using a password at first just so I can get it up and running.

import mysql.connector

class DBCommunicator:

def __init__(self):
    self.conn = mysql.connector.connect(host='mysql.server',
                                        user='marvinfarrell',
                                        database='marvinfarrell$ninjadb')
    self.cursor = self.conn.cursor()

    #####################
    all database operations
    #####################

def __del__(self):
    self.conn.close()

And this is the error I am getting

mysql.connector.errors.ProgrammingError: 1045 (28000): Access denied for user 'marvinfarrell'@'ip-10-120-222-64.ec2.internal' (using password: NO) 2014-04-17 12:02:21,661 :Exception AttributeError: "'DBCommunicator' object has no attribute 'conn'" in <bound method DBCommunicator.del of <database_connection.DBCommunicator object at 0x7f9594bd9d10>> ignored 2014-04-17 12:02:21,665 :Exception AttributeError: "'DBCommunicator' object has no attribute 'conn'" in <bound method DBCommunicator.del of <database_connection.DBCommunicator object at 0x7f95946e6dd0>> ignored

Any help regarding this issue would be greatly appreciated.

The error you're getting is a login failure -- that is, the database is saying that you've given it an invalid combination of username and password, which is because you're not giving it a password at all. You need to provide the password that you set on the "Databases" tab when you connect.

Excellent, thank you very much for your help. It was something that I was overlooking.

No problem, I hope it's all working OK now!