I am trying to connect to a MySQL server with python connector. I created a new user
lcherukuri with the authentication plugin
But I got the error
mysql.connector.errors.NotSupportedError: Authentication plugin "caching_sha2_password" is not supported
Can someone help me?
import mysql.connector cnx = mysql.connector.connect(user="lcherukuri", password="password", host="127.0.0.1", database="test") cnx.close()
I had the same problem and passing
auth_plugin="mysql_native_password" did not work, because I accidentally installed
mysql-connector instead of
mysql-connector-python (via pip3). Just leaving this here in case it helps someone.
In MySQL 8.0,
caching_sha2_passwordis the default authentication plugin rather than
mysql_native_password, which is no longer the default. Assuming you"re using the correct connector for your version you need to specify the
auth_plugin argument when instantiating your connection object
cnx = mysql.connector.connect(user="lcherukuri", password="password", host="127.0.0.1", database="test", auth_plugin="mysql_native_password")
From those same docs:
connect()method supports an
auth_pluginargument that can be used to force use of a particular plugin. For example, if the server is configured to use
sha256_passwordby default and you want to connect to an account that authenticates using
mysql_native_password, either connect using SSL or specify
This question is already answered here and this solution works.
Just try this command :
pip install mysql-connector-python