mysql-connector-python 错误 1045 (28000):使用密码的用户访问被拒绝:是
我在连接 mysql/mariadb 数据库时遇到问题。我在 jupyter 实验室中收到以下错误:
ProgrammingError: 1045 (28000): Access denied for user 'xx'@'yy' (using password: YES)
这是我的代码:
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
我在安装了 mysql-connector-python 8.0.27 的 docker 容器中运行它。我真的很想听听您关于如何解决这个问题的建议。在堆栈上,我只能通过手动调整 pip 中的 mysql 设置来找到解决方案,这对我的情况没有帮助,因为我们需要这个特定版本的 mysql-connector-python 来连接到另一个数据库。有没有办法从 linux bash 解决这个问题?
期待您的来信。
问候, 杰罗姆
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在 mysql.connector 上也遇到了同样的问题。使用 pymysql 模块,它的连接方式相同。只需阅读文档,因为方法参数名称可能不同!
I've had the same problem with
mysql.connector
. Use thepymysql
module, it connects the same way. Just read the documentation because method argument names might not be the same!