简体   繁体   English

Python 中的 MySQL 错误 - 无法连接到 MySQL 服务器

[英]MySQL error in Python - cannot connect to MySQL server

I have a question:我有个问题:

My input:我的输入:

import mysql.connector
import mysql.connector

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

And this is the output:这是输出:

mysql.connector.errors.NotSupportedError: Authentication plugin mysql.connector.errors.NotSupportedError:身份验证插件
'caching_sha2_password' is not supported不支持“caching_sha2_password”

install python MySQL driver安装python MySQL驱动程序
official document官方文件
Similiar stack question类似的堆栈问题
Just make sure that install correct connector based on your operating system, MySQL version and the Python version you use pip install mysql-connector-python只需确保根据您的操作系统、MySQL 版本和您使用的 Python 版本安装正确的连接器 pip install mysql-connector-python

Now it is working thanks!现在它正在工作,谢谢!

i used a mysql plugin so it will work我使用了一个 mysql 插件,所以它可以工作

Thanks!谢谢!

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

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