提问人:SokolSan1 提问时间:11/4/2023 最后编辑:SokolSan1 更新时间:11/4/2023 访问量:43
无法使用 mysql.connector
Can't use mysql.connector
问:
我开始看这个很酷的家伙的烧瓶课(https://www.youtube.com/watch?v=0Qxtt4veJIc&list=PLCC34OHNcOtolz2Vd9ZSeSXWc8Bq23yEz)。我卡在第 9 节课,我需要创建一个 MySQL 表。我安装了:
mysql-connector==2.2.9
mysql-connector-python==8.2.0
mysql-connector-python-rf==2.2.2
在 VScode 中使用 venv(在 Mac 上)
我制作了视频(https://www.youtube.com/watch?v=hQl2wyJvK5k&t=145s)中的所有内容,但是当我开始文件create_db.py时,我得到了这个:
Traceback (most recent call last):
File "/Users/nikitagudkov/Documents/Dev/flasker/create_db.py", line 3, in <module>
mydb = mysql.connector.connect(
File "/Users/nikitagudkov/Documents/Dev/flasker/virt/lib/python3.9/site-packages/mysql/connector/__init__.py", line 179, in connect
return MySQLConnection(*args, **kwargs)
File "/Users/nikitagudkov/Documents/Dev/flasker/virt/lib/python3.9/site-packages/mysql/connector/connection.py", line 95, in __init__
self.connect(**kwargs)
File "/Users/nikitagudkov/Documents/Dev/flasker/virt/lib/python3.9/site-packages/mysql/connector/abstracts.py", line 716, in connect
self._open_connection()
File "/Users/nikitagudkov/Documents/Dev/flasker/virt/lib/python3.9/site-packages/mysql/connector/connection.py", line 208, in _open_connection
self._do_auth(self._user, self._password,
File "/Users/nikitagudkov/Documents/Dev/flasker/virt/lib/python3.9/site-packages/mysql/connector/connection.py", line 137, in _do_auth
packet = self._protocol.make_auth(
File "/Users/nikitagudkov/Documents/Dev/flasker/virt/lib/python3.9/site-packages/mysql/connector/protocol.py", line 99, in make_auth
packet += self._auth_response(client_flags, username, password,
File "/Users/nikitagudkov/Documents/Dev/flasker/virt/lib/python3.9/site-packages/mysql/connector/protocol.py", line 58, in _auth_response
auth = get_auth_plugin(auth_plugin)(
File "/Users/nikitagudkov/Documents/Dev/flasker/virt/lib/python3.9/site-packages/mysql/connector/authentication.py", line 190, in get_auth_plugin
raise errors.NotSupportedError(
mysql.connector.errors.NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported
我认为问题与我下载MySQl的方式或root密码有关?我很乐意得到你的建议!
create_db.py :
import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd="my_passord"
)
my_cursor = mydb.cursor()
my_cursor.execute("CRETE DATABASE our_users")
my_cursor.execute("SHOW DATABASES")
for db in my_cursor:
print(db)
要求.txt :
blinker==1.6.3
click==8.1.7
Flask==3.0.0
Flask-SQLAlchemy==3.1.1
Flask-WTF==1.2.1
importlib-metadata==6.8.0
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.3
mysql-connector==2.2.9
mysql-connector-python==8.2.0
mysql-connector-python-rf==2.2.2
protobuf==4.21.12
SQLAlchemy==2.0.22
typing_extensions==4.8.0
Werkzeug==3.0.0
WTForms==3.1.0
zipp==3.17.0
答: 暂无答案
评论
mysql-connector-python==8.2.0
mysql-connector==2.2.9
mysql-connector-python-rf==2.2.2
mysql-connector-python==8.2.0