Home >Database >Mysql Tutorial >Why Does My Python MySQL Connection Fail with 'Authentication plugin 'caching_sha2_password' is not supported'?
Unable to Connect to MySQL Due to Unsupported Authentication Plugin
While attempting to establish a connection to a MySQL server using the Python connector, you may encounter the error "Authentication plugin 'caching_sha2_password' is not supported." This error can arise when the specified authentication plugin is not supported by the client or server.
Root Cause:
In this particular instance, the root cause of the error is a mismatch between the authentication plugin used to create the user and the plugin supported by the Python connector. By default, the connector supports the "mysql_native_password" authentication plugin, whereas the user "lcherukuri" was created using the "caching_sha2_password" plugin.
Solution:
To resolve this issue, ensure that the authentication plugin used to create the user matches the plugin supported by the connector. In this case, you can specify the "auth_plugin" parameter when establishing the connection, explicitly setting it to "mysql_native_password":
import mysql.connector cnx = mysql.connector.connect(user='lcherukuri', password='password', auth_plugin='mysql_native_password', host='127.0.0.1', database='test') cnx.close()
Additional Notes:
The above is the detailed content of Why Does My Python MySQL Connection Fail with 'Authentication plugin 'caching_sha2_password' is not supported'?. For more information, please follow other related articles on the PHP Chinese website!