MySQL错误 1045 (28000): 用户访问被拒绝

huangapple go评论66阅读模式
英文:

MySQL ERROR 1045 (28000): Access denied for user

问题

我想连接到我的 Django WebAPP 的只读 MySQL 数据库。使用 Django、MySQL Workbench 或 MySQL Shell 始终会导致相同的错误:

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

我能够通过 HeidiSQL 客户端连接,使用相同的配置,但只有在库设置为 libmysql-6.1.dll 时才能成功连接

选择不同的 .dll 始终导致相同的 Error 1045 (28000) : Access denied...

Django 数据库设置:

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

我尝试过以下操作:

  • 使用 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
  • 将 C:\Program Files\MySQL\MySQL Server 8.0\lib 下的 libmysql.dll 更改为 HeidiSQL 的 libmysql-6.1.dll

  • 我尝试了以下 Python 库:pymysql、mysql、MySQLdb、mariadb

英文:

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
MySQL错误 1045 (28000): 用户访问被拒绝

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

答案1

得分: 1

这涉及到版本不一致的问题,与客户端库.dll将密码信息发送给服务器的方式有关。https://stackoverflow.com/questions/59571292/when-do-i-use-libmysql-6-1-dll-vs-libmysql-dll

Ansgar Becker(HeidiSQL的作者)包含了多个不同的库,因为他的最终用户(像我一样)经常需要连接到多个不同的MySQL和MariaDB版本。

尝试重新安装您的Windows客户端MySQL包,包括Python连接器。https://dev.mysql.com/downloads/connector/python/

使用MariaDB版本的客户端包也可能起作用。

英文:

This is version skew, having to do with the way the client library .dll sends password information to the server. https://stackoverflow.com/questions/59571292/when-do-i-use-libmysql-6-1-dll-vs-libmysql-dll

Ansgar Becker (HeidiSQL's author) includes several different libraries, because his end-users (like me) often need to connect to several different MySQL and MariaDB versions.

Try reinstalling your Windows client MySQL packages including the python connector. https://dev.mysql.com/downloads/connector/python/

Using the MariaDB versions of the client packages will probably also work.

答案2

得分: 0

The translated content is as follows:

解决方案是降级 MySQL 版本以支持旧的 TLS 协议版本 1.1 和 1.2。

此外,添加以下参数:

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

到命令中似乎修复了问题。原因是数据库使用的是旧版本的 MongoDB,只支持这些旧协议。

对于任何遇到相同问题的人,这里有一个包含所有支持的 TLS 协议的 MySQL 版本表格:https://dev.mysql.com/doc/refman/8.0/en/encrypted-connection-protocols-ciphers.html

英文:

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

huangapple
  • 本文由 发表于 2023年6月13日 16:50:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/76463198.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定