0

How do I debug this?

mydb = pymysql.connect(
            host="<db-host-ip>",
            port=3306,
            user="<username>",
            password="<password>",
            database="<dbname>"
 )

fails with :

pymysql.err.OperationalError: (1045, "Access denied for user '<myuser>'@'<long_and_boring_hostname>' (using password: YES)")

while this:

mysql --host=<db-host-ip> --user=<username> --password=<password> <dbname>

connects just fine.

I can also connect to the db from java and MySql workbench

I've tried using mysql.connector , same error

I can connect to another db from Python just fine

Why does Python error has long hostname after my username ? can it be suppressed?

** Some more details **

MySql is remote , poython and other tools are local

I am connecting just fine to other databases, only this one seems to conflict.

My main question is how can I troubleshoot this, I need to know more than "Access denied"

JavaHead
  • 635
  • 1
  • 6
  • 21
  • https://stackoverflow.com/questions/20353402/access-denied-for-user-testlocalhost-using-password-yes-except-root-user Does this help at all? – clubby789 Oct 14 '19 at 22:06
  • I don't have root for this db , not sure how it user is configured. – JavaHead Oct 14 '19 at 22:08

1 Answers1

0

Questions: (1) Which computer is running your Python script? (2) Which computer is running your MySQL command-line? (3) Which computer is running MySQL database?

If all 3 of these questions don't have the same answer, then it's possible that you have a port issue in MySQL user administration. In other words, it may be possible that your MySQL server settings are not allowing remote access … if so, there are different ways to troubleshoot but that may require a DBA/expert in MySQL.

Separately, I have used the 'sqlalchemy' Python library and it works well, especially if you run the connection_engine through pandas.read_sql(). I have never used pymysql.