mysql-connector-python error 1045 (28000): Access denied for user using password: YES

2.8k views Asked by At

I am having trouble connecting to a mysql / mariadb database. I am getting the following error in jupyter lab:

ProgrammingError: 1045 (28000): Access denied for user 'xx'@'yy' (using password: YES)

Here is my code:

    import mysql.connector as mariadb

    CONFIG_READ ={'user': 'xx', 'password': 'zz', 
'host': 'myadress', 'database': 'dbname', 'raise_on_warnings': True}  
#i'm sure the entered info here is correct
        
        def read(query, params=()):
            try:
                conn = mariadb.connect(**CONFIG_READ)
                cursor = conn.cursor()
                cursor.execute(query, params)
                result = cursor.fetchall()
            finally:
                conn.close()
            return result

I am running this in a docker container where mysql-connector-python 8.0.27 is installed. I would really like to hear your advise on how to solve this problem. On stack I could only find solutions by manually adjusting mysql settings in pip, that didn't help in my case, since we need this specific version of mysql-connector-python to connect to another db. Is there a way to fix this from linux bash?

Looking forward to hear from you.

Greetings, Jerome

1

There are 1 answers

3
BokiX On

I've had the same problem with mysql.connector. Use the pymysql module, it connects the same way. Just read the documentation because method argument names might not be the same!