简体   繁体   English

无法从 Python 3.8 连接到 MySQL 8

[英]Unable to connect to MySQL 8 from Python 3.8

I am using the following guidelines to connect to MySql8 from my Python code我使用以下指南从我的 Python 代码连接到 MySql8

https://dev.mysql.com/doc/connector-python/en/connector-python-example-connecting.html https://dev.mysql.com/doc/connector-python/en/connector-python-example-connecting.html

When I enter my connection details, I get the following error:当我输入连接详细信息时,出现以下错误:

mysql.connector.errors.NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported

I do not know what the issue could be?不知道是什么问题? The link clearly does not talk about any security or the "Authentication plugin".该链接显然没有谈论任何安全性或“身份验证插件”。

Would appreciate any help possible将不胜感激任何可能的帮助

Many Thanks非常感谢

Sorted!!排序!! I just had to provide the mysql driver to Python.我只需要向 Python 提供 mysql 驱动程序。 Adding to PyCharm or the any IDE is not a solution per se.添加到 PyCharm 或任何 IDE 本身并不是解决方案。

This is what I had to do:这就是我必须做的:

https://www.w3schools.com/python/python_mysql_getstarted.asp

For me, the problem was that I had installed the wrong pip package.对我来说,问题是我安装了错误的 pip 包。 I had installed mysql-connector when in reality I needed mysql-connector-python .当我实际上需要mysql-connector-python时,我已经安装了mysql-connector

pip3 uninstall mysql-connector
pip3 install mysql-connector-python

After I had the correct package, I did not get the error.在我获得正确的包裹后,我没有收到错误消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM