Forums

It doesn't let me connect to mysql on pythonanywhere

Within one of the python files hosted on pythonanywhere gets this error:: mysql.connector.errors.ProgrammingError: 1044 (42000): Access denied for user 'Cristianwiththek'@'%' to database 'users'. The Code Inside That python file is I didn't include the actual password since this is going to be public. Also, this code worked fine when it was using the mysql database hosted on my computer.

import mysql.connector

db = mysql.connector.connect(host='Cristianwiththek.mysql.pythonanywhere-services.com', 
user='Cristianwiththek', passwd='{password goes here}', database='users')
mycursor = db.cursor()


mycursor.execute("SELECT * FROM User")

for x in mycursor:
   print(x)

your database name is probably something like Cristianwiththek$users not users

Thank you so, much putting Cristianwiththek$users instead of just users worked.