import mysql.connector ? mydb = mysql.connector.connect( ? host="localhost", ? ? ? # 数据库主机地址 ? user="root", ? ?# 数据库用户名 ? password="a2251698", ? # 数据库密码 ? auth_plugin = 'mysql_native_password' )
print(mydb)
---------------------------------------------------------------------------
NotSupportedError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_27744/542995535.py in <module>
1 import mysql.connector
2
----> 3 mydb = mysql.connector.connect(
4 host="localhost", # 数据库主机地址
5 user="root", # 数据库用户名
C:\ProgramData\Anaconda3\lib\site-packages\mysql\connector\__init__.py in connect(*args, **kwargs)
177 return CMySQLConnection(*args, **kwargs)
178 else:
--> 179 return MySQLConnection(*args, **kwargs)
180 Connect = connect # pylint: disable=C0103
181
C:\ProgramData\Anaconda3\lib\site-packages\mysql\connector\connection.py in __init__(self, *args, **kwargs)
93
94 if len(kwargs) > 0:
---> 95 self.connect(**kwargs)
96
97 def _do_handshake(self):
C:\ProgramData\Anaconda3\lib\site-packages\mysql\connector\abstracts.py in connect(self, **kwargs)
714
715 self.disconnect()
--> 716 self._open_connection()
717 self._post_connection()
718
C:\ProgramData\Anaconda3\lib\site-packages\mysql\connector\connection.py in _open_connection(self)
206 self._socket.open_connection()
207 self._do_handshake()
--> 208 self._do_auth(self._user, self._password,
209 self._database, self._client_flags, self._charset_id,
210 self._ssl)
C:\ProgramData\Anaconda3\lib\site-packages\mysql\connector\connection.py in _do_auth(self, username, password, database, client_flags, charset, ssl_options)
142 auth_plugin=self._auth_plugin)
143 self._socket.send(packet)
--> 144 self._auth_switch_request(username, password)
145
146 if not (client_flags & ClientFlag.CONNECT_WITH_DB) and database:
C:\ProgramData\Anaconda3\lib\site-packages\mysql\connector\connection.py in _auth_switch_request(self, username, password)
165 (new_auth_plugin,
166 auth_data) = self._protocol.parse_auth_switch_request(packet)
--> 167 auth = get_auth_plugin(new_auth_plugin)(
168 auth_data, password=password, ssl_enabled=self._ssl_active)
169 response = auth.auth_response()
C:\ProgramData\Anaconda3\lib\site-packages\mysql\connector\authentication.py in get_auth_plugin(plugin_name)
188 return authclass
189
--> 190 raise errors.NotSupportedError(
191 "Authentication plugin '{0}' is not supported".format(plugin_name))
NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported
|