Hello-- I'm trying to connect to my PythonAnywhere MySQL database (triley142$golfpool) in a Python script but receive an error when I run the script (please note that I've remove all instances of my actual password with "<password>":
Traceback (most recent call last):
File "/home/triley142/learning/xpath_gptesting.py", line 9, in <module>
db = MySQLdb.connect("triley142.mysql.pythonanywhere-services.com","triley","<password>","triley142$golfpool" )
File "/usr/local/lib/python3.5/dist-packages/MySQLdb/__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/MySQLdb/connections.py", line 204, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1045, "Access denied for user 'triley'@'ip-10-166-167-203.ec2.internal' (using password: YES)")
error when I run the script. Here is the relevant code from the Python script:
#! /usr/bin/env python3
import MySQLdb
db = MySQLdb.connect("triley142.mysql.pythonanywhere-services.com","triley","<password>","triley142$golfpool" )
However, I can access the mysql database through a bash console with the same log in parameters:
12:50 ~ $ mysql -u triley142 -h triley142.mysql.pythonanywhere-services.com -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2298241
Server version: 5.6.27-log MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use triley142$golfpool
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql>
Any idea where I'm going wrong?
[edit by admin: formatting]