I m getting this error again and again whenever i try to connect to MySQL Server -
Error connecting to MySQL: (1045, "Access denied for user 'ansh172003'@'10.0.0.149' (using password: YES)")
the test file im using to check my connection is -
import pymysql
def test_mysql_connection():
# MySQL database credentials
host = 'ansh172003.mysql.pythonanywhere-services.com'
user = 'ansh172003'
password = 'mydatabasepassward'
db_name = 'ansh172003$blogWebsite'
try:
# Establish a connection to the MySQL database
connection = pymysql.connect(
host=host,
user=user,
password=password,
db=db_name,
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor
)
# Connection successful
print("MySQL connection successful!")
# Close the connection
connection.close()
except pymysql.MySQLError as e:
# Connection error
print(f"Error connecting to MySQL: {e}")
if __name__ == "__main__":
test_mysql_connection()
all of my credentials are correct but I still can't connect to database.