Forums

Access denied to MySQL using PythonAnywhere

Hi I am having access denied returned to me when I run a script to open mySQL here is the code. My question is " How can I check that I am keying in the correct password?" in Python Anywhere

#! usr/bin/env python3
import mysql.connector
dbconn = mysql.connector.connect( user = 'mtName', password = 'jmyPassword', host = 'myName.mysql.pythonanywhere-services.com', database = 'myDBName')
mycursor = dbconn.cursor()
query = ('SELECT * FROM table')
mycursor = execute(query)
for (id,name,e_mail,ph_no) in mycursor:
        print('{}, {}, {}'.format(id,name,e_mail,ph_no))
        who = name
        address = e-mail
        phone = ph_no
mycursor.close()
dbconn.close()

I am sure I am entering in the correct connector details etc.

[edited by admin: formatting]

are you running this locally or from pythonanywhere? and what's the exact error message/which line is erroring?

Thanks Big for the response. I discovered that dbconn line had two typos in pointing to the pythonAnywhere database location. Apologies for the inconvience.