Search code examples
pythonmysqldjangoheidisql

MySQL ERROR 1045 (28000): Access denied for user


I want to connect to a readonly MySQL-DB to my Django WebAPP. Using Django, MySQL-Workbench or MySQL-Shell always resulted in the same error:

ERROR 1045 (28000): Access denied for user 'db-foo-read'@'125.67.891.26' (using password: YES)

I was able to connect via HeidiSQL-Client using the same configurations, but only if the library is set to libmysql-6.1.dll enter image description here

Choosing a different .dll always resulted in the same Error 1045 (28000) : Access denied...

Django Database Settings:

'default': {
    'ENGINE': 'django.db.backends.mysql',
    'NAME': 'db-foo',
    'USER': 'db-foo-read',
    'PASSWORD': 'djlkwajldljwj1ldwa1',
    'HOST': '125.67.891.26',
    'PORT': '3306',
},

What i tried:

  • Connect with Shell: "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe" --user="db-foo-read" --password="djlkwajldljwj1ldwa1" --ssl-mode=DISABLED --host="125.67.891.26" --port=3306 --protocol=tcp

  • changing the libmysql.dll @ C:\Program Files\MySQL\MySQL Server 8.0\lib to the HeidiSQL libmysql-6.1.dll

  • I tried following python libraries: pymysql, mysql, MySQLdb, mariadb


Solution

  • Solution was downgrading the mysql version to support old the tls-protocol versions 1.1 and 1.2

    Also adding the parameter

    --tls-version="TLSv1.1,TLSv1.2"
    

    to the command seems to fixed the Issue. Reason was that the DB was using an old Version of MongoDB which only supported these old protocols.

    For anyone having the same Issue, here's a table of all MySQL-Versions with the supported tls protocols: https://dev.mysql.com/doc/refman/8.0/en/encrypted-connection-protocols-ciphers.html