![](/img/trans.png)
[英]ERROR 1045 (28000): Access Denied for 'root'@'localhost' (using password: YES)
[英]mysql-connector-python error 1045 (28000): Access denied for user using password: YES
我無法連接到 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 解決這個問題?
期待着聽到您的意見。
問候,傑羅姆
我遇到了與mysql.connector
相同的問題。 使用pymysql
模塊,它以相同的方式連接。 只需閱讀文檔,因為方法參數名稱可能不一樣!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.