您好,这是我第一次尝试使用mysql连接器从python连接到mysql。我在其他地方找不到这个问题。我正在使用python 3.7和mysql服务器8。
这是我的代码:
import mysql.connector
mydb = mysql.connector.connect(
host = "localhost",
user = "root",
passwd = "password123"
)
print(mydb)
这是我在cmd中运行时遇到的错误:
$ python database.py
Traceback (most recent call last):
File "database.py", line 6, in <module>
passwd = "password123",
File "C:\Users\bryan\AppData\Local\Programs\Python\Python37-32\lib\site-packag es\mysql\connector\__init__.py", line 179, in connect
return MySQLConnection(*args, **kwargs)
File "C:\Users\bryan\AppData\Local\Programs\Python\Python37-32\lib\site-packag es\mysql\connector\connection.py", line 94, in __init__
self.connect(**kwargs)
File "C:\Users\bryan\AppData\Local\Programs\Python\Python37-32\lib\site-packag es\mysql\connector\abstracts.py", line 722, in connect
self._open_connection()
File "C:\Users\bryan\AppData\Local\Programs\Python\Python37-32\lib\site-packag es\mysql\connector\connection.py", line 211, in _open_connection
self._ssl)
File "C:\Users\bryan\AppData\Local\Programs\Python\Python37-32\lib\site-packag es\mysql\connector\connection.py", line 141, in _do_auth
auth_plugin=self._auth_plugin)
File "C:\Users\bryan\AppData\Local\Programs\Python\Python37-32\lib\site-packag es\mysql\connector\protocol.py", line 102, in make_auth
auth_data, ssl_enabled)
File "C:\Users\bryan\AppData\Local\Programs\Python\Python37-32\lib\site-packag es\mysql\connector\protocol.py", line 58, in _auth_response
auth = get_auth_plugin(auth_plugin)(
File "C:\Users\bryan\AppData\Local\Programs\Python\Python37-32\lib\site-packag es\mysql\connector\authentication.py", line 191, in get_auth_plugin
"Authentication plugin '{0}' is not supported".format(plugin_name))
mysql.connector.errors.NotSupportedError: Authentication plugin 'caching_sha2_pa ssword' is not supported