【问题标题】:MySQL error in Python - cannot connect to MySQL serverPython 中的 MySQL 错误 - 无法连接到 MySQL 服务器
【发布时间】:2019-04-10 17:41:30
【问题描述】:

我有一个问题:

我的意见:

import mysql.connector
import mysql.connector

mydb = mysql.connector.connect(
    host = 'localhost',
    user = 'root',
    passwd = 'ananthjeahinowiamshowingmypasswordwitchisnotmypassword'
)
print(mydb)

这是输出:

mysql.connector.errors.NotSupportedError:身份验证插件
不支持“caching_sha2_password”

【问题讨论】:

  • 你的 MySQL 版本是多少?
  • 另外,如果这是真正的密码,可以考虑使用'*****' 在 SO 上发帖。在这种情况下,这可能无关紧要,但总体而言是良好的做法。

标签: python mysql connection


【解决方案1】:

安装 Python MySQL 驱动程序:

Official document

Similar Stack Overflow question

请确保根据您的操作系统、MySQL 版本和您使用的 Python 版本安装正确的连接器:

pip install mysql-connector-python

【讨论】:

    猜你喜欢
    • 2015-09-18
    • 2015-08-09
    • 1970-01-01
    • 1970-01-01
    • 2011-06-19
    • 2014-10-29
    • 2013-01-23
    • 2012-11-30
    • 2013-11-12
    相关资源
    最近更新 更多